使用PHP脚本修改Linux或Unix系统口令
需要的工具和安装:
你必须安装下面的工具和软件:
– 修改口令的Shell脚本;
– Sudo 访问权;
– Apache or Lighttpd web 服务器;
– PHP服务端程序。
步骤1: 安装可以修改用户口令的shell脚本
该脚本可以实际用于修改Linux用户的口令(已在Linux和FreeBSD测试)。
例子: shell脚本代码
#!/bin/sh # \ exec expect -f “$0″ ${1+”$@”} set password [lindex $argv 1] spawn passwd [lindex $argv 0] sleep 1 expect “assword:” send “$password\r” expect “assword:” send “$password\r” expect eof
运行shell脚本(下载链接):
$ chpasswd username password
下载该脚本, 然后拷贝到你的web根目录或者web服务器的其它位置(用户可读):
$ cp chpasswd /var/www/
或者, 如果你使用Lighttpd web服务器:
$ cp chpasswd /home/lighttpd
步骤2: 通过sudo以root身份执行命令
Apache或Lighttpd web服务器进入后台运行后会马上使用非root权限。这样可以很好的防止口令修改, 就像passwd命令需要root权限才能修改其它用户帐号的口令。
通常, Apache 2使用www-data用户, Lighttpd使用lighttpd用户(皆为普通用户, 非root用户)。使用root用户登陆, 然后执行下面的命令:
# visudo现在你的web服务器允许执行口令修改脚本(chpasswd)。如果你使用Apache web服务器, 执行下面的命令:
www-data ALL=NOPASSWD: /var/www/chpasswd
或者, 如果你使用Lighttpd web服务器, 执行下面的命令:
httpd ALL=NOPASSWD: /home/lighttpd/chpasswd
保存和退出文件。
步骤3. 创建一个基于PHP的接口
现在你需要写一个php脚本。这里有一个php脚本实例。你可以根据你的需要来修改。至少你需要正确设置好的shell脚本位置。打开php脚本和找到shellscript一行:
$shellscript = “sudo /home/lighttpd/chpasswd”;
修改shellscript指向到正确的位置。PHP的源代码从这里下载:
步骤4: 运行脚本
在你的web浏览器地址栏输入网地址 - https://mydomain.com/changepassword.php。你将会看到用户名和口令提示:
如果口令修改成功, 你会得到的确认提示:
由于一些原因, 如果口令修改失败, 你可以参考下面提示获得更多详细的错误信息:
步骤5: 安全
◆永远不要通过http协议直接运行上面的脚本. 而是使用https协议。
◆把脚本放入到受口令保护的目录。
◆永远不要信任用户的输入。上面的php脚本只是一个例子。在现实的生产环境中, 你需要考虑采用更强大的用户输入确认。讨论PHP编程的安全超出了本文的范围。你可以参考一本好的PHP书籍或者使用你喜欢的搜索引擎搜索相关的网站。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The world's leading ten digital currency apps include: 1. OKX, 2. Binance, 3. Huobi, 4. Matcha (MXC), 5. Bitget, 6. BitMEX, 7. Pionex, 8. Deribit, 9. Bybit, 10. Kraken. These platforms have their own characteristics in security, transaction services, technical architecture, risk control team, user experience and ecosystem.

Binance is the overlord of the global digital asset trading ecosystem, and its characteristics include: 1. The average daily trading volume exceeds $150 billion, supports 500 trading pairs, covering 98% of mainstream currencies; 2. The innovation matrix covers the derivatives market, Web3 layout and education system; 3. The technical advantages are millisecond matching engines, with peak processing volumes of 1.4 million transactions per second; 4. Compliance progress holds 15-country licenses and establishes compliant entities in Europe and the United States.

The top exchanges include: 1. Binance, the world's largest trading volume, supports 600 currencies, and the spot handling fee is 0.1%; 2. OKX, a balanced platform, supports 708 trading pairs, and the perpetual contract handling fee is 0.05%; 3. Gate.io, covers 2700 small currencies, and the spot handling fee is 0.1%-0.3%; 4. Coinbase, the US compliance benchmark, the spot handling fee is 0.5%; 5. Kraken, the top security, and regular reserve audit.

The charity party hosted by the Langley Community Health and Hospital Foundation raised $331,000 to establish the Guru Nanak Endowment Fund. The donation raised by the "Heart of Giving" charity party for Langley Memorial Hospital has reached one-third of its million-dollar target. On April 4, more than 250 guests attended the annual fundraising event at the Cloverdale Mirage Ballroom. Activities include raffle draws, silent auctions, live auctions and fundraising games, with 50/50 draws continuing until May 2. Since 2019, the Heart of Giving charity party has brought together donors every year to celebrate the community and raise donations, said Heather Scott, executive director of the Langley Community Health and Hospital Foundation. She said: "Testimation

Exchanges play a vital role in today's cryptocurrency market. They are not only platforms for investors to trade, but also important sources of market liquidity and price discovery. The world's largest virtual currency exchanges rank among the top ten, and these exchanges are not only far ahead in trading volume, but also have their own advantages in user experience, security and innovative services. Exchanges that top the list usually have a large user base and extensive market influence, and their trading volume and asset types are often difficult to reach by other exchanges.

The top ten leading virtual currency trading apps in the world in 2025 are: 1. Binance, 2. Gate.io, 3. OKX, 4. Huobi Global, 5. Bybit, 6. Kraken, 7. FTX, 8. KuCoin, 9. Coinbase, 10. Crypto.com.

In today's digital economy era, cryptocurrencies have become the focus of investors and traders. This article will introduce you in detail the ranking of the world's most popular digital currency trading platforms in 2025 to help you make wise choices. These platforms not only provide a variety of cryptocurrency trading pairs, but also have efficient trading systems and powerful security measures. Let's take a deeper understanding of the characteristics and advantages of these top trading platforms.

The top ten Apps of the 2024 currency trading platform are: 1. Binance, the world's largest trading volume, suitable for professional traders; 2. Gate.io, supports a wide range of digital assets and provides pledge services; 3. OKX, has many innovative functions, supports multi-chain trading; 4. Coinbase, has a friendly interface, suitable for beginners; 5. FTX, focuses on derivative trading, and provides low-cost tools; 6. Huobi, high liquidity, and global layout; 7. Crypto.com, comprehensive services, rich reward plans; 8. Bybit, derivative trading platform, suitable for high-frequency trading; 9. KuCoin, a new token initial platform, low fees; 10. Phem
