sd-aws
sdonaws 592047561@qq.com + aa2233zz!!
IP: 18.217.214.174
Ubuntu Server 20.04 LTS (HVM), SSD Volume Type-> t2.micro->添加存储30G
->log in:ubuntu->sudo su
更新系统并安装必要的软件包
sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get -y install curl nano git
sudo apt install unzip
sudo apt install joe 
安装Apache
sudo apt-get install apache2
sudo systemctl restart apache2
安装PHP/PHP-FPM
sudo apt install php7.4-cli
sudo apt-get install php7.4-gd
php -v
->PHP 7.4.14 (cli) (built: Jan 13 2021 08:04:47) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.14, Copyright (c), by Zend Technologies
安装mysql
sudo apt-get install mysql-server
mysql
->Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.22-0ubuntu0.20.04.3 (Ubuntu)
配置mysql
mysql_secure_installation
->root + frevres88->alter user 'root'@'localhost' identified by 'Frevres88!';
创建数据库设置单独的MySQL用户帐户
mysql -u root -p
CREATE DATABASE ocwork CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'ocwork'@'localhost' IDENTIFIED BY 'Frevres88!';
GRANT ALL PRIVILEGES ON *.* TO 'ocwork'@'localhost' WITH GRANT OPTION;
CREATE USER 'phpmyadmin'@'localhost' IDENTIFIED BY 'Frevres88!';
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'localhost' WITH GRANT OPTION;
flush privileges;
select user,host from mysql.user;
sudo systemctl restart mysql
安装phpmyadmin
sudo apt-get install php-mbstring
x-sudo apt-get install php-gettext
sudo apt-get install phpmyadmin
sudo ln -s /usr/share/phpmyadmin /var/www/html/P3-myA5
18.217.214.174/P3-myA5
-->
root密碼太差
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
SHOW VARIABLES LIKE 'validate_password%';
set global validate_password.policy=LOW;
ALTER user 'root'@'localhost' IDENTIFIED BY 'Frevres88!';
------------------------------------------------------------------------------------------------
安裝 opencart
下載 opencart-3.0.3.6.zip
cd /var/www/bk-zip/
wget 118.163.15.73/bpc/dv/upload.zip
x->wget 118.163.15.73/bpc/dv/idea.zip
x->wget 118.163.15.73/bpc/dv/htaccess.txt
x->wget 118.163.15.73/bpc/dv/htaccess-system
x->wget 118.163.15.73/bpc/dv/htaccess-session
cd /var/www/html/
sudo ln -s /usr/share/phpmyadmin /var/www/html/P3-myA5
unzip -q /var/www/bk-zip/upload.zip
x->cp /var/www/bk-zip/htaccess.txt .htaccess.txt
x->cd /var/www/html/system
x->cp /var/www/bk-zip/htaccess-system .htaccess
x->cd /var/www/html/system/storage/session
x->cp /var/www/bk-zip/htaccess-session .htaccess
x->mkdir .idea
x->cd .idea
x->unzip -q /var/www/bk-zip/idea.zip
mv config-dist.php config.php
mv admin/config-dist.php admin/config.php
chmod 777 system/storage/cache/
chmod 777 system/storage/download/
chmod 777 system/storage/logs/
chmod 777 system/storage/modification/
chmod 777 system/storage/session/
chmod 777 system/storage/upload/
chmod 777 system/storage/vendor/
chmod 777 image/
chmod 777 image/cache/
chmod 777 image/catalog/
chmod 777 config.php
chmod 777 admin/config.php
x->chmod 777 /var/www/html/.htaccess.txt
x->chmod 777 /var/www/html/system/.htaccess
x->chmod 777 /var/www/html/system/storage/session/.htaccess
--->cli_install.php 錯誤
/var/www/html/system/library/db/mysqli.php on line 40
Fatal error: Uncaught Exception: Error: Variable 'sql_mode' can't be set to the value of 'MYSQL40'
Error No: 1231
SET @@session.sql_mode = 'MYSQL40' in /var/www/html/system/library/db/mysqli.php:44
-----------------
建空資料庫 oc_work
手工安装 opencart-3.0.3.6
cd install
php cli_install.php install --db_hostname localhost --db_username ocwork --db_password Frevres88! --db_database oc_work --db_driver mysqli --db_port 3306 --username admin --password Frevres88! --email 1837794505@qq.com --http_server http://18.217.214.174/
->
SUCCESS! Opencart successfully installed on your server
Store link: http://18.217.214.174/
Admin link: http://18.217.214.174/admin/
136 张表	总计	5,467	InnoDB	utf8_unicode_ci	550.2 KB	0 字节
->
手工搬整 storage
rm /var/www/storage -rf
mv /var/www/html/system/storage /var/www/
mv /var/www/html/install /var/www/html/install-x
joe /var/www/html/admin/controller/catalog/product.php
->				$image = $this->model_tool_image->resize('no_image.png', 40, 40);
joe /var/www/html/admin/model/tool/image.php
->			if ($width_orig != $width || $height_orig != $height) {
				$image = new Image(DIR_IMAGE . $image_old);
				$image->resize($width, $height);
				$image->save(DIR_IMAGE . $image_new);
			} else {
joe /var/www/html/system/library/image.php
->	public function save($file, $quality = 90) {
//		if (is_resource($this->image)) {
// dv 20210120
		if (is_object($this->image)) {
//dv
if(is_resource($this->image))echo 'res->true
'; if(!is_resource($this->image))echo 'res->false
';
echo 'res->'.(is_resource($this->image)?1:0).'
';
imagecreatefromjpeg
ls /var/www/html/image/cache/ -l
--- 20210119-20 AWS sdonaws 新 account
=========================================================================================================================
root@ip-172-31-40-85:/# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            488M     0  488M   0% /dev
tmpfs           100M   11M   89M  11% /run
/dev/xvda1       30G   20G   10G  66% /
tmpfs           496M     0  496M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           496M     0  496M   0% /sys/fs/cgroup
/dev/loop2       18M   18M     0 100% /snap/amazon-ssm-agent/1566
/dev/loop1       29M   29M     0 100% /snap/amazon-ssm-agent/2012
/dev/loop4       97M   97M     0 100% /snap/core/9665
/dev/loop0       97M   97M     0 100% /snap/core/9804
tmpfs           100M     0  100M   0% /run/user/1000
--- 20200825 AWS-QT ADA 備份下載
=========================================================================================================================
後台打開設定
STORES->Configuration->GENERAL->Reports->General Options->Enable Reports->Yes
清空舊的表
customer_visitor->訪客記錄
report_event->訪問記錄
report_viewed_product_index->訪問產品
(20200502 16:00)
mysqldump -u root -prevres88 --databases magento2 > /var/www/bk-gz/magento2_234_8pm_20200502_1600_ok.sql
(20200503 10:51)
TRUNCATE sales_bestsellers_aggregated_monthly;
SELECT * FROM sales_order_item WHERE created_at < '2020-03-20'; 
DELETE FROM sales_order_item WHERE created_at < '2020-03-20'; (共 54 行)
Bestsellers->You refreshed lifetime statistics.
--- 20200502 AWS-QT most viewed product report 沒有生效 + 新增 Packing Material + 清舊表成功
=========================================================================================================================
cd /var/www/magento2/app/design/frontend/Lee
cp pwc b4u -r
joe b4u/registration.php->
    'frontend/Lee/b4u',
joe b4u/theme.xml->
    
FREE SHIPPING
qt_pwc_dir_50
qt_pwc_dir_68
qt_pwc_dir_65
qt_service
 (products_id=305,307,308,312,355)
12.) 手工去除 ..
13.)  remove whole
--- 20191202 修改舊RO站產品說明 去除href
=========================================================================================================================
1.) 去除 ? ? (76 records)
SELECT * FROM products_description WHERE products_description LIKE '%?%'
UPDATE products_description SET products_description=REPLACE(products_description,'?','') WHERE products_description LIKE '%?%'
2.) 去除 (Please Click Picture to enlarge the picture) (324 + 94 + 52 records)
SELECT * FROM products_description WHERE products_description LIKE '%(Please Click Picture to enlarge the picture)%'
UPDATE products_description SET products_description=REPLACE(products_description,'(Please Click Picture to enlarge the picture)','') WHERE products_description LIKE '%(Please Click Picture to enlarge the picture)%'
UPDATE products_description SET products_description=REPLACE(products_description,'(Please Click ','') WHERE products_description LIKE '%(Please Click %'
UPDATE products_description SET products_description=REPLACE(products_description,'Picture to enlarge the','') WHERE products_description LIKE '%Picture to enlarge the%'
UPDATE products_description SET products_description=REPLACE(products_description,'picture)','') WHERE products_description LIKE '%picture)%'
UPDATE products_description SET products_description=REPLACE(products_description,'Picture to','') WHERE products_description LIKE '%Picture to%'
UPDATE products_description SET products_description=REPLACE(products_description,'enlarge the picture)','') WHERE products_description LIKE '%enlarge the picture)%'
UPDATE products_description SET products_description=REPLACE(products_description,'the picture)','') WHERE products_description LIKE '%the picture)%'
UPDATE products_description SET products_description=REPLACE(products_description,'enlarge','') WHERE products_description LIKE '%enlarge%'
UPDATE products_description SET products_description=REPLACE(products_description,'PW- PW-Picture)','') WHERE products_description LIKE '%PW- PW-Picture)%'
UPDATE products_description SET products_description=REPLACE(products_description,'Picture)','') WHERE products_description LIKE '%Picture)%'
10.) 去除 (82 + 128 records) SELECT * FROM products_description WHERE products_description LIKE '%
%' UPDATE products_description SET products_description=REPLACE(products_description,'
','') WHERE products_description LIKE '%
%'; UPDATE products_description SET products_description=REPLACE(products_description,'
','') WHERE products_description LIKE '%
%'; 11.) 去除
 
 
 
 
 
 
http://cgi5.ebay.com/ws/eBayISAPI.dll?SimilarListing&itemid=110389038550#RO-P1
http://stores.ebay.com/purewaterclub_Water-Filter-System_W0QQcolZ4QQdirZ1QQfclZ4QQfsubZ231976010QQftidZ2QQtZkmQQ_trksidZp1742.m154.l1264
5.)去掉無效說明
  a.) (Please Click Picture to enlarge the picture) -> 324 records
  b.)Great Gift!
      We Could Ship This Item To Your Friend Within US Continatal!
      Good For Your Family And Friends! -> 328 records
6.)去掉破圖 ??
http://59.124.16.10/items/Driver/driver.jpg
7.)去掉下載Download Manual hyper link 32 records
http://59.124.16.10/items/Driver/Protable%20RO%20instruction.doc
8.)去掉Buy It Now價格 194 records
Buy It Now is Just US$108.99 and 2-7 days* you will GET IT at HOME within US!!
9.)去掉Retail Price價格 256 records
(Retail Price:US$320)
SELECT * FROM `products_description` WHERE `products_description` LIKE '%file:%'
--- 20191110 修改舊RO站產品說明
=========================================================================================================================
magento2 table customer_entity->password_hash: 
format -> hash(md5/sha256) : salt (max 32digit) : version (0/1) (md5/sha256) ?->: convet to version (1/2?)
b7de469740dc4f7edf08fe26c4e3ee5a53bf03c5467ff2f02a831c94b707d455:mCIgmxGBoZBGKgL6vkc7xIcZcKUwYQvd:1
v.0登入成功後將主動升級v.1用sha256重寫password_hash
osCommerce 2.4.3.1 table customers->customers_password:
format v.1 -> hash(md5) : salt (2digit)
df7cde40bc6922f8a885a21ebe8fd4b0:70
format v.2 -> $P$ + D(重複作md5次數 D=2^13=8192次) + salt (64進位 8digit) + hash (64進位 21+1digit 最後1位2bit=21*6+2=128=32*4=16進位 32digit)
$P$ D NVAIbn8k ZQQop6d3QAg2lFVkSG2o2 /
./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz (64進位) -> 0123456789abcdef (16進位)
migrate osc to mag2
v.1 -> osc + : + 0
df7cde40bc6922f8a885a21ebe8fd4b0:70 -> df7cde40bc6922f8a885a21ebe8fd4b0:70:0
v.2 -> osc + : + osc去掉首位$ + : + 0
利用mag2的salt位置傳遞存檔hash,新增程式判斷若為osc v.2,則字首加上$後依v.2規則產生hash,比對若正確後回送hash
$P$DNVAIbn8kZQQop6d3QAg2lFVkSG2o2/ -> $P$DNVAIbn8kZQQop6d3QAg2lFVkSG2o2/:P$DNVAIbn8kZQQop6d3QAg2lFVkSG2o2/:0
$P$DYd3TBSaZT6C85hm5amzC8RwGcu3Pf. -> $P$DYd3TBSaZT6C85hm5amzC8RwGcu3Pf.:P$DYd3TBSaZT6C85hm5amzC8RwGcu3Pf.:0
joe /var/www/html/magento8pm/vendor/magento/framework/Encryption/Encryptor.php
1.)新增產生osc v.2的password hash
public function GenPasswordHash($password,$setting){
	$itoa64='./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
	$count_log2 = strpos($itoa64,$setting[3]);
	if ($count_log2 < 7 || $count_log2 > 30)return $output;
	$count = 1 << $count_log2;
	$salt = substr($setting, 4, 8);
	if (strlen($salt) != 8)return $output;
	if (PHP_VERSION >= '5') {
		$hash = md5($salt . $password, TRUE);
		do {
			$hash = md5($hash . $password, TRUE);
		} while (--$count);
	} 
	else {
		$hash = pack('H*', md5($salt . $password));
		do {
			$hash = pack('H*', md5($hash . $password));
		} while (--$count);
	}
	$output = substr($setting, 0, 12);
	$tmpout = '';
	$count=16;
	$i = 0;
	do {
		$value = ord($hash[$i++]);
		$tmpout .= $itoa64[$value & 0x3f];
		if ($i < $count)$value |= ord($hash[$i]) << 8;
		$tmpout .= $itoa64[($value >> 6) & 0x3f];
		if ($i++ >= $count)break;
		if ($i < $count)$value |= ord($hash[$i]) << 16;
		$tmpout .= $itoa64[($value >> 12) & 0x3f];
		if ($i++ >= $count)break;
		$tmpout .= $itoa64[($value >> 18) & 0x3f];
	}while ($i < $count);
	$output .= $tmpout;
	return $output;
}
2.)修改原有的isValidHash(),加入判斷利用salt位置傳遞的hash值是否為osc v.2,並比對由GenPasswordHash()產生的v.2 hash是否正確
    public function isValidHash($password, $hash)
    {
        $this->explodePasswordHash($hash);
        foreach ($this->getPasswordVersion() as $hashVersion) {
//            $password = $this->hash($this->getPasswordSalt() . $password, $hashVersion);
//----- 20191109 DV -------
//--- check if RO Site 2nd password hash ($P$D... 33 digit)->(P$D... 32 digit)
$tmpsalt=$this->getPasswordSalt();
if($hashVersion==0 && substr($tmpsalt,0,3)=='P$D'){
	//--- make hash by salt
	$tmpsalt="$".$tmpsalt;
	//--- check if password OK with SQL hash($ + P$D..)
	if($this->GenPasswordHash($password,$tmpsalt)==$tmpsalt){
		//--- set password -> generated hash
		$password=$tmpsalt;
	}
}
else{
  $password=$this->hash($tmpsalt.$password,$hashVersion);
}
//-----
				}
        return Security::compareStrings(
            $password,
            $this->getPasswordHash()
        );
    }
magento2 核心密碼比對程式
01.)D:/Temp-Downloads/AWS/8pm-zip/vendor/zendframework/zend-crypt/src/Utils.php -> public static function compareStrings($expected, $actual) -> 逐ord()比對產生Hash vs SQLHash -> return true
02.)D:/Temp-Downloads/AWS/8pm-zip/vendor/magento/framework/Encryption/Helper/Security.php -> public static function compareStrings($expected, $actual) -> by pass call (01) -> return true
03.)D:/Temp-Downloads/AWS/8pm-zip/vendor/magento/framework/Encryption/Encryptor.php -> public function isValidHash($password, $hash) ->展開SQLHash成passwordHashMap array,根據不同$hashVersion()+getPasswordSalt()+password產生Hash -> 比對SQLHash+getPasswordHash() call (02) -> return true
03-1.)D:/Temp-Downloads/AWS/8pm-zip/vendor/magento/zendframework1/library/Zend/Crypt.php -> public static function hash($algorithm, $data, $binaryOutput = false)實際產生Hash for (03)
研究用only
/var/www/html/magento8pm/vendor/magento/module-customer/Model/AccountManagement.php
cd /var/www/html/magento8pm/vendor/magento/module-customer/Model/
mv AccountManagement.php-x AccountManagement.php
wget http://61.220.188.84/dv-2019-tmp/AccountManagement.php
wget http://61.220.188.84/dv-2019-tmp/PasswordHash.x
----------------
https://blog.csdn.net/chengfei112233/article/details/6939144/
密码生成方式
> 随机产生一个salt 并将salt和password相加
> 进行了count次md5 然后和encode64的hash数值累加
> 最后得到一个以$P$开头的密码,这个密码每次产生的结果都不一样C:/Users/dv-10/Desktop/catalog/includes/classes/passwordhash.php
系统:MD5(WordPress)
例子:$P$B123456780BhGFYSlUqGyE6ErKErL01
说明:WordPress使用的md5
长度:34个字符
描述:$P$表示加密类型,然后跟着一位字符,经常是字符‘B’,后面是8位salt,后面是就是hash
加密算法:8192次md5循环加密 -> 2的(8+5=13)次方=8192
--- 20191107 遷移舊RO站客戶資料 -> 一元站
=========================================================================================================================
/var/www/html/magento8pm/app/design/frontend/Zou/demo/
x->joe /usr/local/apache/conf/httpd.conf
x->joe /etc/apache2/apache2.conf