在windows的cmd模式,使用ftp指令無法下載。
決定使用winscp來取代。
建立參數檔:script.txt
option batch abort
option confirm off
option transfer binary
open ftp://LoginID:LogPwd@FTP_Host
put d:\examplefile.txt
close
exit
建立執行檔:ftp.bat
winscp.com /script=\script.txt /ini=nul /log=\session.log
將ftp.bat、script.txt放在winscp資料夾
執行ftp.bat即可。也可寫入排程固定執行。
使用sftp
sftp://LoginID:LogPwd@FTP_Host -hostkey="ssh-rsa 1024 XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:X:XX:XX:XX:XX"
使用scp
winscp.exe scp://test@example.com:2222 /privatekey=mykey.ppk
使用ftps
winscp.exe ftps://martin@example.com /implicit /certificate="xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
參考資料:
SFTP使用WinSCP
Useful Scripts
Scripting and Task Automation
Example
In the example below, WinSCP connects to example.com server with account user, downloads file and closes the session. Then it connects to the same server with the account user2 and uploads the file back.
# Connect
open sftp://user:password@example.com/ -hostkey="ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
# Change remote directory
cd /home/user
# Force binary mode transfer
option transfer binary
# Download file to the local directory d:\
get examplefile.txt d:\
# Disconnect
close
# Connect as a different user
open sftp://user2:password@example.com/
# Change the remote directory
cd /home/user2
# Upload the file to current working directory
put d:\examplefile.txt
# Disconnect
close
# Exit WinSCP
exit
Save the script to the file example.txt. To execute the script file use the following command.
winscp.com /ini=nul /script=example.txt
==
For simple scripts you can specify all the commands on command-line using /command switch:
winscp.com /ini=nul /command "open sftp://user:password@example.com/ -hostkey=""ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx""" "get examplefile.txt d:\" "exit"
==
In Windows batch file, you can use ^ to split too long command-line to separate lines by escaping following new-line character:
winscp.com /ini=nul /command ^
"open sftp://user:password@example.com/ -hostkey=""ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx""" ^
"get examplefile.txt d:\" ^
"exit"
See other useful example scripts.
2016年11月22日 星期二
2016年11月18日 星期五
電腦 nginx增加ssl功能
增加ssl
nginx.conf
server {
listen 443 ssl;
server_name www.example.com;
ssl_certificate www.example.com.crt;
ssl_certificate_key www.example.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
...
}
測試ssl
openssl s_client -connect www.example.com:443
worker_processes auto;
nginx.conf
http {
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
server {
listen 443 ssl;
server_name www.example.com;
keepalive_timeout 70;
ssl_certificate www.example.com.crt;
ssl_certificate_key www.example.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
...
server {
listen 443 ssl;
server_name www.example.com;
ssl_certificate www.example.com.crt;
...
}
server {
listen 443 ssl;
server_name www.example.org;
ssl_certificate www.example.org.crt;
...
}
or
nginx.conf
server {
listen 443 ssl;
server_name www.example.com;
ssl_certificate www.example.com.crt;
ssl_certificate_key www.example.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
...
}
測試ssl
openssl s_client -connect www.example.com:443
==HTTPS server optimization
worker_processes auto;
nginx.conf
http {
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
server {
listen 443 ssl;
server_name www.example.com;
keepalive_timeout 70;
ssl_certificate www.example.com.crt;
ssl_certificate_key www.example.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
...
==Name-based HTTPS servers
server {
listen 443 ssl;
server_name www.example.com;
ssl_certificate www.example.com.crt;
...
}
server {
listen 443 ssl;
server_name www.example.org;
ssl_certificate www.example.org.crt;
...
}
or
server {
listen 192.168.1.1:443 ssl;
server_name www.example.com;
ssl_certificate www.example.com.crt;
...
}
server {
listen 192.168.1.2:443 ssl;
server_name www.example.org;
ssl_certificate www.example.org.crt;
...
}
==
An SSL certificate with several names
ssl_certificate common.crt;
ssl_certificate_key common.key;
server {
listen 443 ssl;
server_name www.example.com;
...
}
server {
listen 443 ssl;
server_name www.example.org;
...
}
Configuring HTTPS servers
電腦 Linux-將IIS的SSL憑證移至Centos使用
將IIS 匯出的 PKCS12 憑證檔 (mycert.pfx) 轉換
openssl pkcs12 -in mycert.pfx -out mycert.txt -nodes
輸入憑證密碼,建立 mycert.txt 檔案
mycert.txt 檔案,裡面同時包含兩個憑證,分別是 伺服器私鑰(RSA PRIVATE KEY) 與 伺服器憑證(CERTIFICATE)
將mycert.txt中包含
-----BEGIN RSA PRIVATE KEY-----
-----END RSA PRIVATE KEY-----
複製到server.key
將mycert.txt中包含
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
複製到server.crt
就可以將server.key、server.crt導入到網站(apache、nginx)使用
將 IIS 中已安裝的 SSL 憑證移至 Apache 2.2 for Win32 安裝
2016年11月17日 星期四
電腦 CentOS yum server 建置-對外更新
Yum Server 建置-對外更新
新增硬碟(40G)為/data,放置更新檔。
建立更新目錄
mkdir -p /data/centos/7
安裝相關更新套件
yum install yum-utils createrepo
下載套件
cd /data/centos/7
reposync --repoid=updates --repoid=extras --repoid=base
建立索引檔
createrepo /data/centos/7/base/
createrepo /data/centos/7/extras/
createrepo /data/centos/7/updates/
建立網站服務,讓client更新
使用httpd
yum install httpd
systemctl start httpd
systemctl enable httpd
建立更新目錄連結
mkdir -p /var/www/html/centos/7/updates /var/www/html/centos/7/extras/ /var/www/html/centos/7/base/
cd /var/www/html/centos/7/updates && ln -s /data/centos/7/updates/ x86_64 && cd -
cd /var/www/html/centos/7/extras && ln -s /data/centos/7/extras/ x86_64 && cd -
cd /var/www/html/centos/7/base && ln -s /data/centos/7/base/ x86_64 && cd -
建立更新repo
vim /etc/yum.repos.d/local.repo
[local-base]
name=Local Server-base
baseurl=http://192.168.1.72/centos/7/base/x86_64
enabled=1
[local-extras]
name=Local Server-extras
baseurl=http://192.168.1.72/centos/7/extras/x86_64
enabled=1
[local-updates]
name=Local Server-updates
baseurl=http://192.168.1.72/centos/7/updates/x86_64
enabled=1
指定由local更新
yum update --disablerepo="*" --enablerepo="local*"
每月定期更新排程
vi /etc/cron.monthly/repoupdate.sh
#!/bin/sh
cd /data/centos/7
reposync --repoid=updates --repoid=extras --repoid=base
createrepo /data/centos/7/base/
createrepo /data/centos/7/extras/
createrepo /data/centos/7/updates/
chomd +x /etc/cron.monthly/repoupdate.sh
2016年11月16日 星期三
電腦 CentOS yum server建置-使用iso檔
Yum Server建置-使用iso檔
本機
1.掛載iso檔
a.在vmware環境下,光碟機先掛載iso檔,不用上傳至主機。
ls -l /dev/cdrom
mount /dev/cdrom /mnt
mount /dev/cdrom /mnt
b.直接上傳iso檔至主機,將iso檔掛載至/mnt。
mount -o loop,ro CentOS-7-x86_64-Everything-1511.iso /mnt/cdrom
2.新增local.repo
vim /etc/yum.repos.d/local.repo
[local]
name=Local ISO
baseurl=file:///mnt/cdrom
gpgcheck=0
enabled=1
3.指定由local更新
yum update --disablerepo="*" --enablerepo="local"
指定由local安裝httpd
yum install --disablerepo="*" --enablerepo="local" httpd
其它主機可以經由http或ftp協定更新
a.使用httpd
yum install --disablerepo="*" --enablerepo="local" httpd
指定路徑
cd /var/www/html
ln -sf /mnt
啟用httpd
systemctl start httpd
systemctl enable httpd
b.使用vsftpd
yum install --disablerepo="*" --enablerepo="local" vsftpd
修改登匿名者登入目錄
echo 'anon_root=/mnt' >> /etc/vsftpd/vsftpd.conf
啟用httpd
systemctl start vsftpd
systemctl enable vsftpd
c.新增local.repo,看要http或ftp。
vim /etc/yum.repos.d/local.repo
[local]
name=Local ISO
baseurl=http://192.168.1.72/mnt
baseurl=ftp://192.168.1.72/
gpgcheck=0
enabled=1
3.指定由local更新
yum update --disablerepo="*" --enablerepo="local"
指定由local安裝httpd
yum install --disablerepo="*" --enablerepo="local" httpd
mount -o loop,ro CentOS-7-x86_64-Everything-1511.iso /mnt/cdrom
2.新增local.repo
vim /etc/yum.repos.d/local.repo
[local]
name=Local ISO
baseurl=file:///mnt/cdrom
gpgcheck=0
enabled=1
3.指定由local更新
yum update --disablerepo="*" --enablerepo="local"
指定由local安裝httpd
yum install --disablerepo="*" --enablerepo="local" httpd
其它主機可以經由http或ftp協定更新
a.使用httpd
yum install --disablerepo="*" --enablerepo="local" httpd
指定路徑
cd /var/www/html
ln -sf /mnt
啟用httpd
systemctl start httpd
systemctl enable httpd
b.使用vsftpd
yum install --disablerepo="*" --enablerepo="local" vsftpd
修改登匿名者登入目錄
echo 'anon_root=/mnt' >> /etc/vsftpd/vsftpd.conf
啟用httpd
systemctl start vsftpd
systemctl enable vsftpd
c.新增local.repo,看要http或ftp。
vim /etc/yum.repos.d/local.repo
[local]
name=Local ISO
baseurl=http://192.168.1.72/mnt
baseurl=ftp://192.168.1.72/
gpgcheck=0
enabled=1
3.指定由local更新
yum update --disablerepo="*" --enablerepo="local"
指定由local安裝httpd
yum install --disablerepo="*" --enablerepo="local" httpd
2016年11月14日 星期一
電腦 nginx增加modsecurity功能
modsecurity 安裝
wget https://www.modsecurity.org/tarball/2.9.1/modsecurity-2.9.1.tar.gz
tar -zxvf modsecurity-2.9.1.tar.gz
cd modsecurity-2.9.1
./configure --enable-standalone-module --disable-mlogc
make
nginx 安裝
wget http://nginx.org/download/nginx-1.10.2.tar.gz
tar -zxvf nginx-1.10.2.tar.gz
cd nginx-1.10.2
./configure --add-module=../modsecurity-2.9.1/nginx/modsecurity/
modsecurity設定
cp ../modsecurity-2.9.1/modsecurity.conf-recommended /etc/nginx/modsecurity.conf
cp ../modsecurity-2.9.1/unicode.mapping /etc/nginx/
vim nginx.conf
增加
ModSecurityEnabled on;
ModSecurityConfig modsecurity.conf;
測試
nginx -t
啟用nginx後,檢查error.log
增加 OWASP ModSecurity Core Rule Set (CRS) 規則
git clone https://github.com/SpiderLabs/owasp-modsecurity-crs.git
or
wget https://github.com/SpiderLabs/owasp-modsecurity-crs/archive/v3.0.0.tar.gz
tar zxvpf v3.0.0.tar.gz
mv owasp-modsecurity-crs-3.0.0/ /etc/nginx/owasp-modsecurity-crs
cp crs-setup.conf.example crs-setup.conf
cp rules/REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf.example rules/REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf
cp rules/RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf.example rules/RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf
新增 modsec_includes.conf
include modsecurity.conf
include owasp-modsecurity-crs/crs-setup.conf
如果需要其它規則也可以加入
include owasp-modsecurity-crs/rules/REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf
修改nginx.conf
將
ModSecurityConfig modsecurity.conf;
更改為
ModSecurityConfig modsec_includes.conf;
重新載入nginx
Cross-site Scripting test request
http://192.168.1.106/search.aspx?txtSearch=%3Cscript%3Ealert%28%27foo%27%29%3C%2Fscript%3E
電腦 Windows Server試用序號
Windows Server試用序號
Windows Server 2008 R2 Web: KBV3Q-DJ8W7-VPB64-V88KG-82C49
Windows Server 2008 R2 Standard: 4GGC4-9947F-FWFP3-78P6F-J9HDR
Windows Server 2008 R2 Enterprise: 7PJBC-63K3J-62TTK-XF46D-W3WMD
Windows Server 2008 R2 Datacenter: QX7TD-2CMJR-D7WWY-KVCYC-6D2YT
Windows Server 2008 R2 Evaluation Product Keys
Windows Server 2012
D2N9P-3P6X9-2R39C-7RTCD-MDVJX
Windows Server 2012 R2 Evaluation Product Keys
到期後延長使用期限
Windows Server 2008 R2 SP1 評估版與延長使用期限
Windows Server 2008 R2 180天試用期延展
Windows Server 2008 R2 Web: KBV3Q-DJ8W7-VPB64-V88KG-82C49
Windows Server 2008 R2 Standard: 4GGC4-9947F-FWFP3-78P6F-J9HDR
Windows Server 2008 R2 Enterprise: 7PJBC-63K3J-62TTK-XF46D-W3WMD
Windows Server 2008 R2 Datacenter: QX7TD-2CMJR-D7WWY-KVCYC-6D2YT
Windows Server 2008 R2 Evaluation Product Keys
Windows Server 2012
D2N9P-3P6X9-2R39C-7RTCD-MDVJX
Windows Server 2012 R2 Evaluation Product Keys
到期後延長使用期限
Windows Server 2008 R2 SP1 評估版與延長使用期限
Windows Server 2008 R2 180天試用期延展
訂閱:
文章 (Atom)
