2025/03/20

之前一直都是使用nc來傳資料到 syslog
但這几天發現做好的檔案都被砍了
反正eset現在不允許nc的執行
另外找了一個 sfk
之前有試過 但當時有不少bug
語法如下

sfk oload log.txt +udpsend 10.0.0.1:514


2025/03/15

最近又有人反應讀取mail的速度很慢
讀寫大量小檔的效能基本上很難提升
查到使用 noatime nodiratime 應該可以改善一些
原理讀取時不會再去update 檔案資訊 
這裡說的資訊如下 

stat test

檔案:test
  大小:87              區塊:8          IO 區塊:4096   一般檔案
裝置:801h/2049d        Inode:15466774    實際連結 (hardlink) :1
權限:(0664/-rw-rw-r--)    Uid:( 1000/      aa)  Gid:( 1000/      aa)
最近存取:2025-03-15 08:40:59.971496391 +0800
最近變更:2020-10-14 05:42:44.007905808 +0800
最近變更:2020-10-14 05:42:44.059906505 +0800
建立時間:-

把以上二個參數加到 /etc/fstab裡要作用的分區 再remount 即可

UUID=xxxx-xxxx-xxxx-xxxx /home xfs defaults,noatime,nodiratime 0 0


再觀察看看效果有多少

2025/03/12

最近要移除client端的軟体
包括 anydesk teamviewer winrar java 等等
一開始的想法是從eset protect定期下指令
於是設定了以下指令排程

"%ProgramFiles(x86)%\anydesk\anydesk.exe" --silent --remove
"%ProgramFiles%\TeamViewer\uninstall.exe" /S
"%ProgramFiles(x86)%\TeamViewer\uninstall.exe" /S
"%programfiles%\WinRAR\uninstall.exe" /s
"%programfiles(x86)%\WinRAR\uninstall.exe" /s

但發現不一定會有 uninstall.exe 這個檔案 所以不一定會成功
接著查到可以使用 powershell來處理 指令如下

powershell -Command "Get-WmiObject -Query 'SELECT * FROM Win32_Product WHERE Name LIKE ''Java%'' AND vendor LIKE ''oracle%''' | ForEach-Object { $_.Uninstall() }"

試了一下 powershell指令無法直接從eset protect直接下

為了執行時不跳出訊息
只能依照之前的做法 寫成uninstall.vbs   再加入client排程

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "powershell -Command ""Get-WmiObject -Query 'SELECT * FROM Win32_Product WHERE Name LIKE ''Java%'' AND vendor LIKE ''oracle%''' | ForEach-Object { $_.Uninstall() }""", 0, False


schtasks /create /tn "uninstall task" /tr "C:\ProgramData\uninstall.vbs" /sc weekly /d MON /st 09:00 /ru abc /f

之後如果需要再移除其他軟体 再更改 uninstall.vbs重新派送即可


20250329 補充

在某些狀況下 還是需要切換到系統管理員身分才有作用
必須再安裝 gsudo 
安裝後使用 gsudo 執行指令 才行

2025/02/14

今天在 almalinux 9 dnf update出現以下錯誤


Error:

Problem: package iptables-legacy-1.8.10-4.1.el9.x86_64 from @System requires (iptables-libs(x86-64) = 1.8.10-4.el9 or iptables-libs(x86-64) = 1.8.10-4.el9_4), but none of the providers can be installed

- cannot install both iptables-libs-1.8.10-11.el9_5.x86_64 from baseos and iptables-libs-1.8.10-4.el9_4.x86_64 from @System

- cannot install both iptables-libs-1.8.10-4.el9_4.x86_64 from baseos and iptables-libs-1.8.10-11.el9_5.x86_64 from baseos

- cannot install the best update candidate for package iptables-libs-1.8.10-4.el9_4.x86_64

- cannot install the best update candidate for package iptables-legacy-1.8.10-4.1.el9.x86_64

(try to add '--allowerasing' to command line to replace conflicting packages or '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

本來想把iptables-legacy iptables-libs 都移除 但因為這台跑docker 如果移除會連docker一起移掉

查到官方 forum有人提供解法

dnf --assumeyes swap iptables-legacy iptables-nft


https://forums.almalinux.org/t/almalinux-9-yum-update-iptables-legacy-and-iptables-libs-conflict/3818/2

2025/02/06

要如何讓使用者能看影片但不被下載

首先把 mp4 分片

ffmpeg -i abc.mp4 -codec: copy -start_number 0 -hls_time 15 -hls_list_size 0 -f hls abc.m3u8

分片後把 abc.mp4 移出目錄


建立 index.html


<html>
<head>
  <link href="https://vjs.zencdn.net/8.16.1/video-js.css" rel="stylesheet" />

  <!-- If you'd like to support IE8 (for Video.js versions prior to v7) -->
  <!-- <script src="https://vjs.zencdn.net/ie8/1.1.2/videojs-ie8.min.js"></script> -->
</head>

<body>
  <video
    id="my-video"
    class="video-js"
    controls
    preload="auto"
    width="640"
    height="480"
    刪除以下一行
    poster="MY_VIDEO_POSTER.jpg"
    data-setup="{}"
  >
    <source src="MY_VIDEO.mp4" type="video/mp4" />
    <source src="MY_VIDEO.webm" type="video/webm" />
   刪除以上二行

    把第一步產生的所有分片檔放到 web server 的目錄 並依需求修改以下文字

    <source src='http://10.0.0.1/test/abc.m3u8' type="application/x-mpegURL">   
    
    <p class="vjs-no-js">
      To view this video please enable JavaScript, and consider upgrading to a
      web browser that
      <a href="https://videojs.com/html5-video-support/" target="_blank"
        >supports HTML5 video</a
      >
    </p>
  </video>

  <script src="https://vjs.zencdn.net/8.16.1/video.min.js"></script>
</body>
</html>


用browser打開即可觀看


2025/01/23

本次ZAP弱掃出現二個Medium


其實上次就有 不過這次要求連Medium都要處理
看來二個都是CSP的問題
之前改過一次版面會亂
這次再處理看看吧
要修改 /etc/apache2/apache2.conf 
加上以這這段

<IfModule mod_headers.c>

        Header set Content-Security-Policy "\
        default-src 'self';\
        img-src 'self' http://10.0.0.1 http://www.fcounter.net http://s11.flagcounter.com data:;\
        frame-src 'self' https://abc.com.tw https://www.youtube.com;\
        style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://cdnjs.cloudflare.com;\
        script-src 'self' https://cdn.jsdelivr.net https://code.jquery.com https://cdn.datatables.net 'unsafe-eval' 'unsafe-inline';\
        font-src 'self' https://cdnjs.cloudflare.com;\
        "

</IfModule>

內容需要依照自己的需求去修正
一個網頁一個網頁去看格式有沒亂掉 版面有沒正常
可以打開 browser 的開發人員工具
會顯示那些被CSP阻擋了
然後再補上去
需要補什麼問 https://www.perplexity.ai/ 比較快
把主控台上的訊息直接問就可以了

不難 但真的很花時間

2025/01/16

今天登入n8n看到通知





















想說之前升級都沒問題就沒先snapshot
結果升完後出現白畫面
只好倒回備分
再下一版看看吧

之後要升一定要先snapshot