2021年10月22日 星期五
2021年7月21日 星期三
Apache CGI
httpd.conf example
<Directory "C:/Apache2/cgi-bin">
#AllowOverride None
#Options None
Options +ExecCGI
AddHandler cgi-script .cgi .pl
Require all granted
</Directory>
cgi or perl 程式需要放到指定的 cgi-bin 目錄內執行。 很多 cgi 或 perl 都是採用 #!/usr/bin/perl 的宣告 。所以避免修改原有程式可以將 active perl 安裝於 C:\usr\ 目錄內,這樣就不需要修改現有程式。若是按 perl 預設安裝路徑那就需要修改為 #!C:\Perl64\bin\perl.exe。
相關參考:
2021年3月9日 星期二
SFTP 安裝@ Windows
步驟
@windows
應用程式內新增 OpenSSH伺服器
@powershell
Start-Service sshd
Set-Service -Name sshd -StartupType 'Automatic'
Get-NetFirewallRule -Name *ssh* //檢視規則
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH SSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 //調整規則
調整 ssh_config 檔案 (%programdata%\ssh) & restart sshd
Port 22
ForceCommand internal-sftp //強制僅使用 sftp connections
Subsystem sftp sftp-server.exe -d "C:\Data_SFTP\"
ChrootDirectory C:\Data_SFTP //指定連線到特定目錄
AllowUsers sftpuser //加強管理
AllowGroups sshusers //加強管理
Logging //Windows OpenSSH 預設會記錄在事件檢視器。若要調整為記錄於檔案內需做以下調整。
LogLevel INFO | VERBOSE | Debug3 (視需求)
ChrootDirectory C:\Apache2\htdocs
ForceCommand internal-sftp
X11Forwarding no
AllowTcpForwarding no
ChrootDirectory C:\Apache2\htdocs\sftp_user
ForceCommand internal-sftp
X11Forwarding no
AllowTcpForwarding no
參考資料
- 在Windows 10架設SFTP(SSH Server)
- OpenSSH Server configuration for Windows Server and Windows
- Windows – How to restrict users to sftp in OpenSSH on Windows Server
- Windows 的 OpenSSH
- 如何為特定用戶設置SFTP登入後到chroot特定目錄?
- 適用于 Windows 10 1809 和 Windows Server 2019 的 OpenSSH 伺服器設定
- SSH Tunnel 設定方式 Windows 10
- 透過 OpenSSH 使用 SFTP 登入時將帳戶設為 chroot 的方法 (Linux)
- SFTP 的登入位置
- OpenSSH 金鑰管理
- [Security] 你該知道所有關於 SSH 的那些事
2021年2月18日 星期四
透過Adguard 阻擋Youtube APP廣告
Adguard 若僅透過瀏覽器使用 Youtube 觀看影片,它的阻擋廣告效果很好但在手機上直接透過 Youtube APP 觀看影片的效果有限。
現在 Adguard 有提供一個方式可有效阻擋廣告,在操作上也僅需要幾個步驟即可。
Android 或 iOS 使用 Youtube APP 操作上僅有兩個步驟:
- Open YouTube app and start the video you want to watch. (在 youtube APP 打開要看的影片)
- Tap on the Share button and select AdGuard for Android from the list of apps. (在分享按鈕那點一下分享給Adguard 即可)
相關參考:
2021年2月6日 星期六
Apache SSL Cipher Suite
加密演算法也是資安的評量點。
設定的參考可以使用 moz://a SSL Configuration Generator 所建議的 Cipher Suite 設定。
設定值:
SSLProtocol -all +TLSv1.2 +TLSv1.3 //刪除所有的 protocol 並加入 TLSv1.2 , TLSv1.3
也可以這樣子寫
SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1 // 使用所有的 protocol 不使用SSLv3 ,TLSv1,TLSv1.1
SSLProxyProtocol (與 SSLCipherSuite 的設定相同)
SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
SSLProxyCipherSuite (與 SSLCipherSuite 的設定相同)
SSLUseStapling On //加快 SSL certificate 驗証
# HTTP Strict Transport Security (mod_headers is required) (63072000 seconds)
Header always set Strict-Transport-Security "max-age=63072000"
檢測 SSL Cipher 檢測工具
- nmap : e.g. nmap --script ssl-enum-ciphers -p 443 Server_IP -P0 | find "EXP"
- sslscan windows
參考資料:
- Strong SSL Security on Apache2
- Security/Server Side TLS
- moz://a SSL Configuration Generator
- CVE-2015-4000 檢測方式與修補方式
- SSLCipherSuite Directive
- Apache 啟用 OCSP ,加快網站速度
- 讓你的 SSL 更安全 – 移除弱 SSL 加密方式 (Cipher)
- SS Labs
2020年11月20日 星期五
youtube-dl
基本上也是因為新聞才注意到此工具。基本上類似這類的工具不少,透過一些線上平台的服務使用就有相同的功能,使用上只要在平台頁面內貼上要下載的網址就可以下載。有些安裝在電腦內的付費版本軟體則有額外再提供轉檔等功能 (如,MP4 轉 MP3)。但這些功能 youtube-dl 也都有提供,且它也不僅只有支援 youtube 平台,它所支援的影音平台眾多。
簡單的註記使用方式:
下載:
youtube-dl webiste , windows UI Portable
外掛(有轉檔需求才需要):
ffmpeg, ffmpeg windows (ffmpeg-N-99931-ge3081d6f4f-win64-gpl-shared-vulkan 39.2MB ,不是很明白不同版本的差異,我是找容量最小的版本使用)
設定方式(@ windows):
將下載的檔案放到指定的位址。設定作業系統內的環境變數,Path 路徑指定到程式放的位置。
軟體更新:
youtube-dl -U
使用範例:
youtube-dl <url> (自動會取最佳畫質)
youtube-dl <url> -F (看看有那些格式可以下載)
youtube-dl <url> -f 22+140 (指定要的格式與聲音下載 ; 數字由 -F 所呈現的資訊決定)
youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' <url> (直接讓程式決定自動下載最佳所指定的影片+聲音 ; Download best mp4 format available or any other best if no mp4 available)
youtube-dl -x --audio-format mp3 <url> (直接抓取 mp3)
youtube-dl -x --audio-format mp3 --embed-thumbnail --add-metadata <url> (轉檔成mp3並加入縮圖與影片資訊)
youtube-dl -f mp4 <playlist-url> (下載整份影片清單)
youtube-dl <url1> <url2> <url3> (下載多個指定的影片)
youtube-dl -f best -a list.txt (按檔案內的清單下載)
youtube-dl -f best <url>
youtube-dl -f 'bestvideo+bestaudio/bestvideo+bestaudio' --merge-output-format mp4 <url>
youtube-dl -f 'bestvideo[ext=webm]+bestaudio[ext=m4a]/bestvideo+bestaudio' --merge-output-format mp4 <url>
youtube-dl -f 'bestvideo+bestaudio[ext=m4a]' --merge-output-format mp4 <url>
下載 facebook 不開放社團內影片 youtube-dl --username=your account email --password=yourpassword https://www.facebook.com/video_URL
111.02.18 不知為什麼採上以上方式會出現 This video is only avaliable for registered user. 但確認登入的帳密是有效的。後來改用 cookie 的方式來抓取
cookie 的方式:
1. export cookie txt files (e.g. firefox export cookie puglin),保留 facebook cookie 即可。
2. youtube-dl --cookies C:\Temp\cookie.txt <facebook video url>
ffmpeg 影片切割
ffmpeg -ss 00:00:30.0 -i input.mp4 -c copy -to 00:01:30.0 output.mp4 (起訖時間;訖的時間由起開始計算)
教學參考:
- How to Install Youtube-DL on Windows
- youtube-dl Format Selection
- 用 youtube-dl 優雅下載 YouTube 影片
- Youtube-dl濃縮教學筆記
- shell - youtube-dl DASH視頻和音頻,無需人工干預即可獲得最高質量
- 影音剪輯 / 使用 ffmpeg 分割影片 (指定開始及結束時間或固定時間長度分割)
- FFmpeg无损快速切割视频方法
- 懶人剪影片法(使用終端機指令)
注意事項:
- 下載Youtube音樂或影片合法嗎?
- MP3音樂檔案下載是否違法?
- [法律授權] 我可以在自己的網站上使用那支影片嗎? Youtube、Vimeo、Vine,Instgram
- 你以為的 YouTube 無版權音樂竟然侵權?讓創作者苦惱的著作權問題
- 鏈結youTube影片不構成侵害著作權 ?
- 盜版線上看,不下載不犯法?
- 【法律白話文運動】線上的盜版影片違反著作權法,那我線上追劇有沒有違法?
2020年10月11日 星期日
調整相片 exif 日期
Example:
exiftool "-DateTimeOriginal+=9:9:7 02:42:0" "D:\pics_1091009\1091009"
exiftool "-DateTimeOriginal+=9:9:7 02:42:0" "D:\pics_1091009\1091010"
說明:針對目錄 1091009 內的檔案,時間加上 9:9:7 (9 年 9 個月 7 天)以及 02:42:0 (2 個小時 42 分 0 秒)
軟體下載:
相關參考:
https://jerome.anyday.com.tw/archives/143