參考面網址
http://twpug.net/modules/smartfaq/faq.php?faqid=8
$curl = curl_init("https://localhost/test.php);
這行有點小錯誤, 應該是
$curl = curl_init("https://localhost/test.php");
代碼:
$PostData = "foo=abc&bar=def";
$curl = curl_init("https://10.3.0.34/a3.php");
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1); //這行請參考 http://curl.haxx.se 的介紹
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); //這行請參考 http://curl.haxx.se 的介紹
//設定伺服器憑證,要不要像我忘了... 請自己 try 一下
//curl_setopt($curl, CURLOPT_CAPATH, "/certificate");
//curl_setopt($curl, CURLOPT_CAINFO, "/certificate/server.crt");
//不直接顯示回傳結果
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
//post資料給指定網頁
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $PostData);
$Result = curl_exec($curl);
curl_close($curl);
?>
資料送出
-----
1. 開啟 php_openssl
2. 範例 fsockopen()
代碼:
$set_userid = "admin";
$set_passwd = "123456";
$POST_VALUES = "my_userid=" . $set_userid . "&my_passwd=" . $set_passwd;
$fp = fsockopen("ssl://192.168.0.1", 443, $errno, $errstr, 30);
if ($fp){
$out = "";
$out .= "POST /my_service/login.php HTTP/1.1\r\n";
$out .= "Host: 192.168.0.1\r\n";
$out .= "Accept: text/html\r\n";
$out .= "Connection: close\r\n";
$out .= "Content-Type: application/x-www-form-urlencoded\r\n";
$out .= "Content-length: " . strlen($POST_VALUES) . "\r\n";
$out .= "\r\n";
$out .= ($POST_VALUES) . "\r\n";
fputs($fp, $out);
while (!feof($fp)){
$log .= fgets($fp, 1024);
}
fclose($fp);
}
echo $log;
來源: http://forum.icst.org.tw/phpbb/viewtopic.php?t=10151
2009年10月25日 星期日
2007年8月18日 星期六
由php建立shadow密碼
如果把/etc/shadow搬到mysql裡面當作使用者認證
這時passwd將無法改變資料庫的密碼
可以改用php的方式去改變
在php中有crypt可用
但是在不同系統似乎會有不同結果
例如在13.13可以直接產生正確的 CRYPT_MD5 密碼
但是在26.7卻會產生 CRYPT_BLOWFISH 密碼
$salt_str='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.';
$salt=substr(str_shuffle($salt_str), 0, 8);
因此必須手動處理crypt的干擾碼:str_shuffle會隨機從字串中選出
substr才可以選其中八碼來用
最後crypt('aaa', '$1$'.$salt) 便可以產生正確的 CRYPT_MD5密碼給shadow使用
這時passwd將無法改變資料庫的密碼
可以改用php的方式去改變
在php中有crypt可用
On systems where the crypt() function supports multiple encryption types, the following constants are set to 0 or 1 depending on whether the given type is available:
CRYPT_STD_DES - Standard DES-based encryption with a two character salt
CRYPT_EXT_DES - Extended DES-based encryption with a nine character salt
CRYPT_MD5 - MD5 encryption with a twelve character salt starting with $1$
CRYPT_BLOWFISH - Blowfish encryption with a sixteen character salt starting with $2$ or $2a$
但是在不同系統似乎會有不同結果
例如在13.13可以直接產生正確的 CRYPT_MD5 密碼
但是在26.7卻會產生 CRYPT_BLOWFISH 密碼
$salt_str='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.';
$salt=substr(str_shuffle($salt_str), 0, 8);
因此必須手動處理crypt的干擾碼:str_shuffle會隨機從字串中選出
substr才可以選其中八碼來用
最後crypt('aaa', '$1$'.$salt) 便可以產生正確的 CRYPT_MD5密碼給shadow使用
訂閱:
文章 (Atom)