2021年12月24日 星期五

如何從把原本在MAC的Parallels desktop 的windows 10的虛擬機升級到windows 11, Parallels Desktop windows 10 VM upgrade to windows 11 on a MAC

Windows 11已經出一段時間了 

但是parallels desktop的win10 vm一直沒有出現更新windows 11

結果是我的VM不符合windows 11升級之資格

要把Parallels Desktop 的Windows 10 VM升級到Windows 11有些步驟

Some steps to upgrade Parallels Desktop's Windows 10 VM to Windows 11

1.要把Parallels Desktop 升級到17.1以後版本 

1. To upgrade Parallels Desktop to version 17.1 or later

2.需把win10 VM升級到2004之後的版本

2. Need to upgrade win10 VM to the version after 2004

3.VM記憶體需要有4GB以上,儲存空間需有64GB以上,Win10 需有正版授權

3.VM memory needs to be 4GB or more, storage space needs to be 64GB or more, and Win10 needs a genuine license

4.把VM關機

4.Turn off the VM

5.在Win10 VM的控制中心組態的硬體 左下角的+號按下去增加 TPM晶片的硬體

5.Open VM configuration settings > Hardware 

Scroll down the hardware list and check if the TPM chip is added:

如下parallels的介紹

https://kb.parallels.com/en/128559

6.Win10 VM開機 按開始->設定->Windows Update 就會出現Windows 11的升級可以更新

6.Boot Win10 VM and press Start->Settings->Windows Update, and Windows 11 upgrade can be updated.

或是 執行電腦健康情況檢查應用程式後 下載 Windows 11安裝小幫手 就可以升級Windows 11

Or after running the Widnows PC Health Check APP, download Windows 11 Installation Assistant to upgrade Windows 11

2021年12月23日 星期四

某個罕見的中文字在asp.net 網站使用report viewer 產生的 pdf無法顯示會變成方匡

今天遇到一個中文字的狀況
就是在asp.net 網站產生的PDF 無法顯示那個中文字在mac電腦也無法顯示那個中文字

但是在windows下用winform 程式用word元件產生的pdf卻可以顯示那個字 

這個字如下網頁在Windows 下可以顯示字 但是mac無法顯示那個字https://ctext.org/dictionary.pl?if=gb&char=%F0%A5%A1%A5

後來找到原因是因為原本網頁的report viewer 是2010

只要更新成report viewer 2015 後就可以正常顯示 下面可以抓

Report Viewer 2015 Runtime

再裝Report Viewer 2015 RunTime前可能要先裝SQLSysClrTypes For SQL Server 2014

SQL Sys Clr Types For Sql Server 2014

更新需把web.config 更新一下

在<system.web><assembly>

<add assembly="Microsoft.ReportViewer.WebForms, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>

<add assembly="Microsoft.ReportViewer.Common, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/> 

在<system.webServer><handlers>下

<add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />


更新之後再從web重新產生pdf那個奇怪的 種 字 就可以正常顯示在mac的pdf也可以看到他

2021年11月9日 星期二

安裝Visual Studio 2022 後Visual Studio 2019 專案無法載入 出現error: 無法開啟專案檔。找不到.NET SDK。請檢查是否安裝該項目,且在global.json中指定版本(如果有的話)是否安裝版本相符

昨天正式發表Visual Studio 2022 所以就來安裝 
結果我安裝Visual Studio 2022後 Visual Studio 2019 全部的專案都無法載入 出現
"error: 無法開啟專案檔。找不到.NET SDK。請檢查是否安裝該項目,且在global.json中指定版本(如果有的話)是否安裝版本相符。"
 如下圖
英文為
“The project file cannot be opened. Unable to locate the .NET SDK. Check that it is installed and that the version specified in global.json (if any) matches the installed version.”
上網都查不到原因 google了很久
查到這個網站有解法
https://hamidmosalla.com/2021/03/13/unable-to-locate-the-net-sdk-the-reasons/

在環境變數裡面的Path 把C:\Program(x86)\donet\ 刪掉就可以正常開啟專案了
原因是安裝VS2022時多選擇安裝了.net 5 runtime

電腦按右鍵內容->進階->環境變數
環境變數->系統變數->Path->編輯

找到C:\Program Files(x86)\dotnet\ 按刪除


2021年9月8日 星期三

CS0656 遺漏編譯器必要成員'Microsoft.CSharp.RuntimeBinder.Binder.Convert'

 把.net framework 3.5的專案升級到.net framework 4.8時出現了一個錯誤如圖

CS0656 遺漏編譯器必要成員'Microsoft.CSharp.RuntimeBinder.Binder.Convert'

英文是 "Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.Binder.Convert'"



上網找到解決方法就是加入一個參考 在C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\Microsoft.CSharp.dll

如下圖

然後就可以正常編譯過了

2021年6月6日 星期日

Dell R740 出現Unable to access Front LED Panel because of a hardware condition

 今天Dell R740 的Server 竟然出現

Unable to access Front LED Panel because of a hardware condition
還有紅底白字的 System HAS CRITICAL ISSUES
現場人去現場看LED 前面板顯示也很奇怪
結果call Dell維修竟然 說更新iDrac就可以了
所以就照著指示去更新到4.40.10.00完之後就正常了 錯誤訊息就不出現了

以下為Dell客服的回覆




2021年5月13日 星期四

ASP.Net Web Forms網站 掃出 ASP.NET debugging enabled 弱點

 ASP.Net Web Forms網站 掃出 ASP.NET debugging enabled 弱點

解決方法 關掉debugging

在web.config

修改設定為<compilation debug="false"/>

ASP.Net Web Forms網站 掃出 Cookies with missing, inconsistent or contradictory properties 弱點 Cookie without SameSite attribute

 ASP.Net Web Forms網站 掃出 Cookies with missing, inconsistent or contradictory properties 弱點

Cookie without SameSite attribute

原因cookie少了sameSite屬性

解決方法:

修改web.config增加sameStie屬性

增加 <httpCookies sameSite="Strict">設定

然後cookie就會多了一個sameSite的屬性了





ASP.Net Web Forms網站 掃出 Clickjacking: X-Frame-Options header missing 弱點

 ASP.Net Web Forms網站 掃出 Clickjacking: X-Frame-Options header missing 弱點


解決方法:增加X-Frame-Options的HTTP標頭欄位

怎麼加勒?還是修改web.config 

增加以下設定

<httpProtocol>

    <customHeaders>

      <add name="X-Frame-Options" value="SAMEORIGIN" />

    </customHeaders>

  </httpProtocol>


ASP.Net Web Forms網站 掃出 ASP.NET version disclosure 弱點

 ASP.Net Web Forms網站 掃出ASP.NET version disclosure弱點

風險等級:低

Header會出現一個X-ASPNET-Version 告訴你網站是哪個.net framewrok版本

是沒必要的

解決方法:

在web.config加入以下設定值

<System.Web>

 <httpRuntime enableVersionHeader=''false'' />

</System.Web>


加完後Header就不會有X-ASPNET-Version了



ASP.Net Web Forms網站 掃出 Unencrypted __VIEWSTATE parameter 弱點

 有一個舊的ASP.Net Web Forms 網站 掃出了弱點名稱:Unencrypted __VIEWSTATE parameter

風險等級:中

修補方式:

修改Web.config並於<system.web>下添加

<machineKey validation="AES"/> 

改完後VIEWSTATE會變成加密的如下圖








2021年5月11日 星期二

在Mantis 中顯示“真實姓名”

 mantis都只有顯示username雖然有輸入真實姓名但是只有管理者看得到

很難知道回報者到底是誰且還有使用者名稱相似的一直認錯

上網google後 發現需要修改config_inc.php 

加上下面設定就好了

$g_show_realname = ON;


mantis文件參考網址入下

https://www.mantisbt.org/docs/master/en-US/Admin_Guide/Admin_Guide.txt

2021年4月28日 星期三

Install Moxa NPort Real TTY drivers for Linux 5.x.x on Ubuntu 20.04

今天開會同事說安裝Moxa的Nport driver 在Ubuntu 20.04上無法complier

所以我自己下載了一個ubuntu 20.04安裝看看 結果成功了

首先到moxa網站如下網址下載driver

https://www.moxa.com/getmedia/c075914f-6187-4f7f-a1c8-e444389d69e8/moxa-real-tty-drivers-for-linux-5.x.x-driver-v5.0.tgz

解開這個檔案後裡面有一個readme.txt 打開會寫如何安裝driver 然後有一個system Requirement如下所示 所以就照順序每個套件安裝 

System Requirement

    To install this driver, you will need NPort Server and one of the
    following system.

     -  kernel 3.0 or above and the kernel source package
     -  gcc-2.7.2.1 or above
     -  ld.so-1.7.14 or above
     -  libc.so-5 or above
     -  binutils-2.7.0 or above
     -  make-3.74 or above
     -  gunzip-1.2.4 or above
     -  gawk-3.1.1.9 or above
     -  openssl-1.0.0 or above (For Secure Real COM Mode only)
     -  libssl-dev-1.0.0 or above (For Secure Real COM Mode only)
     
    Additional requirements for Raspbian
     -  gcc-4.8.3 or above
     -  ncurses-devel-5.9 or above
     -  rpi-source, read the instruction from it's website.

    

1.先安裝Ubuntu 20.04

2.然後安裝gcc 指令如下
sudo apt update
sudo apt install build-essential

3.安裝
libc.so
指令如下
sudo ln -s /lib64/x86_64-linux-gnu/libc.so.6 /lib64/libc.so.6

4.安裝binutils指令如下
sudo apt-get update -y

sudo apt-get install -y binutils-common

5.安裝make指令如下
sudo apt-add-repository ppa:ubuntu-desktop/ubuntu-make 

sudo apt-get update 

sudo apt-get install ubuntu-make 


6.安裝gunzip指令如下

sudo apt-get update -y

sudo apt-get install -y gzip


7.安裝gawk 指令如下
sudo apt-get update -y

sudo apt-get install -y gawk


8.安裝openssl指令如下(nport 6系列才有用)

sudo apt update

sudo apt install openssl

9.安裝libssl指令如下(nport 6系列才有用)

sudo apt install libssl-dev


10.安裝ncurses-devel (樹莓派才需要)
Sudo apt install ncurses-devel

ncurses-devel


11.重新開機
reboot

12.安裝Nport Real TTY drivers for Linux 5.x.x
解壓縮到moxa目錄 cd到 moxa目錄執行
sudo ./mxinst


然後出現如下字串安裝成功
===============================================================================
Installation process is completed.
The all driver files are installed on /usr/lib/npreal2/driver.
Now you can cd /usr/lib/npreal2/driver and run ./mxaddsvr to add tty port.
===============================================================================

安裝過程截圖如下





















2021年4月8日 星期四

ASP .Net Core MVC 3.1 偵測到漏洞 HSTS Missing From HTTPS Server (RFC 6797)

ASP .Net Core MVC 3.1 的網站使用nessus弱點掃描
偵測到漏洞 HSTS Missing From HTTPS Server (RFC 6797)
原本網站的 Startup.cs 的HTTPS Redirect寫成
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)        {
  app.UseForwardedHeaders();
            app.Use(async (context, next) =>
            {
                if (context.Request.IsHttps || context.Request.Headers["X-Forwarded-Proto"] == Uri.UriSchemeHttps)
                {
                    await next();
                }
                else
                {
                    string queryString = context.Request.QueryString.HasValue ? context.Request.QueryString.Value : string.Empty;
                    var https = "https://" + context.Request.Host + context.Request.Path + queryString;
                    context.Response.Redirect(https);
                }
            });

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();
}

改成
 services.Configure<ForwardedHeadersOptions>(options =>
            {
                options.ForwardedHeaders =
                    ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
                options.KnownNetworks.Clear();
                options.KnownProxies.Clear();
            });
            services.AddHttpsRedirection(opt => opt.HttpsPort = 443);
//其他省略
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            app.UseForwardedHeaders();
            app.Use(async (context, next) =>
            {
                context.Response.Headers.Add("X-Frame-Options", "SAMEORIGIN"); // Or this
                await next();
            });

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();
//其他省略
}

然後就正常了



解決 ASP .Net Core MVC 3.1 的Clickjacking弱點

 弱掃偵測偵測到一個ClickJacking的弱點

Web Application Potentially Vulnerable to Clickjacking

解決方法在 Startup.cs 的Configure 加上 header SAMEORIGIN 如下方程式碼

或是加上deny 不能同時加 同時加就會500

app.Use(async (context, next) =>
	{
	context.Response.Headers.Add("X-Frame-Options", "SAMEORIGIN");
	await next();
	});