11/27/2023

win11 cannot open security panel - fix issue with powershell cmd

type "powershell" in search bar and choose run with admin and type in following cmd:

 Get-AppxPackage Microsoft.SecHealthUI -AllUsers | Reset-AppxPackage


secure more for win11 login

 @echo off

REM *** Make sure to run this script with administrative privileges ***


REM *** Backup the registry ***

reg export HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System backup.reg


REM *** Modify the registry ***

reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v dontdisplaylastusername /t REG_DWORD /d 1 /f


echo Registry modification complete.


REM *** Optional: Display the modified registry key ***

reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v dontdisplaylastusername


pause


11/22/2023

如何將 NIST 網路安全框架套用到您的系統上

 要將 NIST 網路安全框架套用到您的系統上,您可以遵循以下步驟:


步驟 1:評估系統的現狀


首先,您需要評估您的系統的現狀,包括其安全措施、風險和漏洞。您可以使用各種工具和方法來進行評估,例如:


資訊安全風險評估:資訊安全風險評估是一種系統性的方法,用於識別和評估系統面臨的安全風險。

滲透測試:滲透測試是一種模擬攻擊者嘗試入侵系統的過程,以識別系統的安全漏洞。

資訊安全診斷:資訊安全診斷是一種全面的評估,用於識別系統的安全問題。

在進行評估時,您需要關注以下方面:


系統的資產和資訊:您需要識別系統中的重要資產和資訊,包括數據、應用程式和系統。

系統面臨的風險:您需要識別系統面臨的安全風險,包括自然災害、人為錯誤和惡意攻擊。

系統的安全措施:您需要評估系統現有的安全措施,包括防火牆、入侵偵測系統和安全策略。

步驟 2:制定改進計劃


根據評估結果,您需要制定改進計劃,以提高系統的安全性。改進計劃應包括以下內容:


具體的目標和措施:您需要明確改進計劃的目標,並制定具體的措施來實現目標。

責任人和時間表:您需要指定每項措施的責任人和時間表。

評估和監控機制:您需要制定評估和監控機制,以確保措施得到有效實施。

在制定改進計劃時,您需要考慮以下因素:


組織的風險承受能力:您需要根據組織的風險承受能力,制定合理的改進計劃。

組織的資源能力:您需要根據組織的資源能力,制定可行的改進計劃。

步驟 3:實施改進措施


根據改進計劃,您需要實施改進措施。在實施過程中,您需要進行定期評估,以確保措施得到有效實施。


在實施改進措施時,您需要注意以下事項:


充分溝通:您需要充分溝通改進措施的內容和目的,以獲得組織成員的理解和支持。

逐步推進:不要試圖一次性實施所有改進措施。您需要根據組織的情況,逐步推進改進措施,以確保措施得到有效實施。

步驟 4:持續監控和改進


資訊安全是一個持續的過程。您需要持續監控系統的安全性,並根據需要進行改進。


在持續監控時,您需要關注以下方面:


系統的安全狀態:您需要定期評估系統的安全狀態,以確保系統的安全性。

新的安全威脅:您需要關注新的安全威脅,並採取措施應對新的安全威脅。

在改進時,您需要根據監控結果,制定新的改進措施,以保持系統的安全性。


以下是一些具體的實施步驟建議:


識別功能域


建立資產清單,包括數據、應用程式和系統等。

使用風險評估方法,識別系統面臨的安全風險。

保護功能域


實施防火牆、入侵偵測系統和安全策略等安全控制。

管理系統的訪問權限,並定期進行身份驗證和授權。

偵測功能域


監控系統的環境,以識別可能的安全威脅或事件。

使用安全監控和事件管理系統,收集和分析安全事件。

回應功能域


制定安全事件響應計劃,以在發生安全威脅或事件時採取措施。

建立應急計劃,以應對自然災害等意外事件。

復原功能域


制定災難復原計劃,以在發生災難時恢復系統和資訊。

11/14/2023

What is CORS

 CORS stands for Cross-Origin Resource Sharing. It is a security feature implemented by web browsers to control how web pages in one domain can request and interact with resources hosted on another domain.


In a web application, a web page often makes requests to a different domain for resources such as images, stylesheets, scripts, or data through XMLHttpRequest or Fetch API. However, due to the same-origin policy enforced by web browsers, these requests are typically restricted to the same domain for security reasons.


CORS allows a server to specify who can access its resources and under what conditions. It involves both server-side HTTP headers and client-side JavaScript APIs.


Here's a brief overview of how CORS works:


Client-Side (Browser): When a web page makes a cross-origin request using JavaScript (e.g., through XMLHttpRequest or Fetch API), the browser adds an "Origin" header to the request, indicating the origin (domain, protocol, and port) of the requesting site.


Server-Side (Server): The server then needs to handle this request and include appropriate CORS headers in the response. These headers include:


Access-Control-Allow-Origin: Specifies which origins are allowed to access the resource. It can be a specific origin, a comma-separated list of origins, or a wildcard (*) indicating that any origin is allowed.

Access-Control-Allow-Methods: Specifies the HTTP methods (e.g., GET, POST) that are allowed when accessing the resource.

Access-Control-Allow-Headers: Specifies which HTTP headers can be used when making the actual request.

Access-Control-Allow-Credentials: Indicates whether the browser should include credentials (like cookies or HTTP authentication) when making the actual request.

Access-Control-Expose-Headers: Specifies which headers should be exposed to the browser in the response.

Preflight Requests: For certain types of requests (e.g., those with certain methods or headers), the browser may send a preflight request (an HTTP OPTIONS request) to the server to check if the actual request is safe to send. The server responds with the appropriate CORS headers to indicate whether the actual request should proceed.


CORS is an important security feature that helps prevent malicious websites from making unauthorized requests on behalf of a user. It enables controlled sharing of resources across different origins while maintaining security on the web.

11/08/2023

前端簡單防禦機制 JS 防止按右鍵 與 開發者模式

<script type="text/javascript">

document.onkeydown = function (event) {

     event = (event || window.event);

     if (event.keyCode == 123 || event.keyCode == 18)

     {

           return false;

     }

}

document.addEventListener('contextmenu', event => event.preventDefault());

</script>



chatGPT:

  <script>

    document.oncontextmenu = document.onkeydown = function(e) {

      if (e.keyCode === 123 || e.type === 'contextmenu') {

        e.preventDefault();

      }

    };

  </script>

3/24/2023

Password policy on macOS

 There are several ways to enforce password policies on a Mac to ensure that users apply strong passwords that meet the required security standards. Here are some steps you can take:


Enable the password policy: Open the "Terminal" application and run the following command:


sudo pwpolicy -setglobalpolicy "policyAttribute=required"


This will enable the password policy on the Mac.


Set the password policy requirements: Run the following command to set the password policy requirements:


sudo pwpolicy -u <username> -setpolicy "newPasswordRequired=1"


Replace <username> with the actual username of the user account you want to set the password policy for. This command will require the user to create a new password that meets the password policy requirements.


Define the password policy requirements: You can define the specific password policy requirements by running the following command:


sudo pwpolicy -u <username> -setpolicy "minChars=8"


Replace <username> with the actual username of the user account you want to set the password policy for. The minChars option specifies the minimum number of characters required for the password. You can also set other options such as maxChars, minDigits, minLetters, minUppercase, minLowercase, minSpecialChars, and history.


Disable the ability to change password: If you want to prevent users from changing their passwords, you can run the following command:


sudo dscl . -passwd /Users/<username> -policy "isDisabled=1"


Replace <username> with the actual username of the user account you want to set the policy for. This will disable the ability to change the password for that user account.


Note that enforcing password policies on a Mac may require administrative privileges. You should also inform your users about the password policy requirements and educate them about creating strong passwords to enhance the overall security of the system.


This setting may be enforced using local policy or by a directory service.


To set local policy to require at least 1 lowercase letter, edit the current password policy to contain the following <dict> within the "policyCategoryPasswordContent":


[source,xml]

----

<dict>

<key>policyContent</key>

<string>policyAttributePassword matches &apos;(.*[A-Z].*){1,}+&apos;</string>

<key>policyIdentifier</key>

<string>Must have at least 1 uppercase letter</string>

<key>policyParameters</key>

<dict>

<key>minimumAlphaCharactersUpperCase</key>

<integer>1</integer>

</dict>

</dict>

----

After saving the file and exiting to the command prompt, run the following command to load the new policy file, substituting the path to the file in place of "$pwpolicy_file".


[source,bash]

----

/usr/bin/pwpolicy setaccountpolicies $pwpolicy_file

----

NOTE: See the password policy supplemental on more information on how to implement password policies on macOS.

3/04/2023

How to test XProtect with EICAR file

 EICAR (European Institute for Computer Antivirus Research) is a test file designed to help test antivirus and other security software. You can use EICAR to test if XProtect is working by following these steps:


Open TextEdit or any other text editor on your Mac.


Type the following string into a new document:


X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*

Save the document with the file name "eicar.com". Note that you should select the "Plain Text" format when saving the file, and not the default "RTF" format.


Once the file is saved, your Mac's XProtect should detect the file and display a warning message. If XProtect is working properly, it should prevent you from opening or running the file, and inform you that it has detected a potential threat.


By using the EICAR test file, you can verify that XProtect is able to detect and block potentially harmful files on your Mac. It's important to note that you should only use the EICAR test file for testing purposes, and never use it as a real virus or malware.

3/03/2023

Default or built in mechanism in Mac OS

 Mac OS includes a number of built-in security features to protect users and their data. Some of the default security mechanisms provided in Mac OS are:


Firewall: Mac OS includes a built-in firewall that helps prevent unauthorized access to your computer. The firewall can be configured to allow or deny incoming connections from specific applications or services.


FileVault: FileVault is a built-in encryption feature that can encrypt the entire contents of your Mac's hard drive. This helps protect your data if your Mac is lost or stolen.


Gatekeeper: Gatekeeper is a feature that helps protect your Mac from malware by only allowing apps from the App Store or identified developers to be installed.


XProtect: XProtect is a built-in antivirus feature that helps protect your Mac from known malware threats.


Safari security features: The Safari web browser included with Mac OS includes a number of built-in security features, such as the ability to block pop-ups, disable Java and Flash, and warn you if you are visiting a potentially dangerous website.


Keychain Access: Keychain Access is a password management tool that is built into Mac OS. It securely stores your passwords and other sensitive information, and can also generate strong passwords for you.


System Integrity Protection (SIP): System Integrity Protection is a security feature that is designed to prevent malicious software from modifying important system files and directories.


Overall, Mac OS includes a number of built-in security features that are designed to help protect your Mac and your data from a variety of threats.

how to do reverse engineer of a PE file for malware analysis

 Reverse engineering a PE file for malware analysis can be a complex process that requires knowledge of assembly language and various reverse engineering tools. Here are some general steps to get started:


Obtain the malware sample: You can obtain a malware sample from a trusted source or capture it from a compromised system.


Analyze the PE header: The Portable Executable (PE) header contains information about the executable file. You can use tools like PEView or PE Explorer to view the header information.


Disassemble the code: To analyze the malware's behavior, you need to disassemble the code to understand the instructions that the malware is executing. You can use a disassembler like IDA Pro or Ghidra to disassemble the code.


Analyze the functions: Malware often uses a variety of functions to perform its malicious actions. You need to identify the relevant functions and analyze their behavior.


Analyze the network traffic: Malware often communicates with a command and control (C&C) server. You need to analyze the network traffic to identify the C&C server and any data that the malware is sending or receiving.


Analyze the file system activity: Malware often creates, modifies, or deletes files on the system. You need to monitor the file system activity to identify any malicious behavior.


Look for anti-analysis techniques: Malware authors often use techniques to evade detection and analysis. You need to look for anti-analysis techniques like obfuscation, encryption, and anti-debugging techniques.


Document your findings: You should document your analysis findings, including the behavior of the malware, any indicators of compromise (IOCs), and any anti-analysis techniques used.

3/01/2023

penetration test process

 Penetration testing is the process of identifying and exploiting vulnerabilities in a system or network to assess its security posture. Here are the general steps involved in a penetration testing process:


Planning and reconnaissance: This involves understanding the scope of the penetration test, defining objectives, and gathering information about the target system or network.

Scanning: In this step, the penetration tester uses automated tools to scan the target system or network for vulnerabilities.

Enumeration: In this step, the tester manually investigates the target system or network to identify potential attack vectors.

Vulnerability analysis: The tester analyzes the results of the scanning and enumeration steps to identify and prioritize vulnerabilities based on their potential impact and ease of exploitation.

Exploitation: The tester attempts to exploit the identified vulnerabilities to gain unauthorized access to the target system or network.

Post-exploitation: If the tester is successful in gaining access, they may attempt to escalate their privileges, maintain access, and exfiltrate sensitive data.

Reporting: The tester documents their findings and provides a report to the organization outlining the vulnerabilities discovered, the potential impact of each vulnerability, and recommendations for remediation.

Remediation: The organization uses the penetration testing report to remediate the identified vulnerabilities and improve the security posture of the target system or network.


It's worth noting that these steps are not necessarily linear, and a penetration test may involve iterations of these steps to identify and exploit different vulnerabilities.

2/18/2023

Can cloudflare block all kinds of sql injection attack?

Cloudflare provides some protections against SQL injection attacks, but it cannot guarantee to block all types of attacks.

Cloudflare's Web Application Firewall (WAF) includes a set of predefined rules that can help protect against common SQL injection attacks, as well as other types of attacks. These rules can be customized and tuned to the specific needs of your website or application.

However, it is important to note that Cloudflare's WAF is not foolproof and may not catch all types of attacks. There are also advanced and sophisticated SQL injection techniques that may bypass these protections, especially if the attacker specifically targets your website or application.

In addition to using Cloudflare's WAF, it is recommended to take other steps to prevent SQL injection attacks, such as using parameterized queries, input validation, and least privilege access control. Regular security assessments and vulnerability testing can also help identify and address any weaknesses in your application's security.

2/15/2023

企業資安強化項目

當今社會的資訊化程度越來越高,資安問題也日益嚴峻。為了提高企業的資安防護能力,我們建議實施以下強化項目:

首先,企業應該加強員工資安意識的培養。很多資安事件都是由於員工不慎或不知情而引起的,因此企業需要加強資安教育培訓,讓員工熟悉常見的資安攻擊手段和防範措施,增強他們的資安防護意識。

其次,企業應該對系統進行嚴格的訪問控制。訪問控制可以限制未經授權的用戶或設備訪問敏感資料和系統,減少資安風險。此外,企業還可以實現身份驗證、加密傳輸等技術手段來加強系統的安全性。

另外,企業應該建立完善的監控系統,實時監控系統運行狀態和異常行為,及時發現和處理潛在的資安問題。此外,企業還可以建立漏洞管理機制,及時處理系統和應用程序中的漏洞,避免被攻擊者利用。

最後,企業應該定期進行資安風險評估,發現和評估系統和應用程序中的潛在風險,制定相應的風險應對措施,減少資安風險。同時,企業還應該定期進行網絡滲透測試,模擬攻擊者的攻擊行為,發現系統和應用程序中的安全漏洞和弱點,進行修補和加固。

總之,企業的資安防護工作不僅是一個技術問題,還需要從員工資安意識、系統訪問控制、監控和漏洞管理等方面綜合考慮,全方位提高資安防護能力。

2/01/2023

common insecure coding situations

 Here are some common insecure coding situations:

  1. Buffer overflows: Allocating insufficient memory for user input can lead to buffer overflows and allow attackers to execute arbitrary code.
  2. SQL Injection: Failing to properly validate user input when constructing SQL queries can allow attackers to inject malicious SQL commands into the database.
  3. Cross-Site Scripting (XSS): Failing to validate user input when generating dynamic web pages can allow attackers to inject malicious scripts into a web page that can then be executed in the user's browser.
  4. Cross-Site Request Forgery (CSRF): Not protecting forms and other sensitive operations from being executed by unauthorized users can result in attackers tricking users into performing actions they didn't intend to.
  5. Unsecured sensitive data: Storing sensitive data, such as passwords, in plaintext or using weak encryption methods, can make it vulnerable to attacks.
  6. Unvalidated Redirects and Forwards: Failing to validate user input when redirecting or forwarding to a new URL can allow attackers to redirect users to malicious sites.
  7. Inadequate error handling: Not properly handling exceptions and errors can reveal sensitive information and make it easier for attackers to exploit vulnerabilities.
  8. Insecure communication: Not using secure protocols, such as SSL or TLS, to encrypt communication can make it vulnerable to eavesdropping and man-in-the-middle attacks.
  9. Insecure storage: Not properly securing files, directories, and other resources on the server can result in attackers accessing sensitive information or modifying data.
  10. Use of vulnerable libraries: Using libraries with known security vulnerabilities can make the application vulnerable to attacks.

These are just a few common insecure coding situations. It's important to stay informed about the latest security threats and to follow secure coding practices to minimize the risk of security vulnerabilities in your code.

how to find security related bugs in java code

Finding security bugs in Java code requires a systematic approach. Some steps to follow include:

Code review: Manually inspect the code for potential security vulnerabilities, such as buffer overflows, SQL injection, etc.

Static analysis: Use automated tools to scan the code for security issues, such as FindBugs, SonarQube, or Fortify.

Dynamic analysis: Use runtime testing techniques, such as penetration testing or fuzz testing, to identify potential security issues.

Library analysis: Check if any third-party libraries used in the code have known security vulnerabilities and if they have been updated to the latest version.

Keep up-to-date with security advisories and patches: Stay informed about the latest security threats and apply any relevant patches to address security vulnerabilities.

It's also important to follow secure coding practices, such as input validation, error handling, and using secure coding frameworks, to minimize the risk of security bugs in your Java code.

1/31/2023

是否有可以偵測異常登入的開源套件

Yes, there are open-source tools that can detect unusual login activity:

OSSEC: A Host-based Intrusion Detection System (HIDS) that monitors and alerts on unusual login activity.

Suricata: A Network Intrusion Detection System (NIDS) that can detect and alert on unusual login activity.

AIDE: A file integrity monitoring tool that can detect and alert on changes to login-related files.

Snort: A Network Intrusion Prevention System (NIPS) that can detect and alert on unusual login activity.

SELinux: A mandatory access control (MAC) system for Linux that can restrict and log unusual login activity.

These are just a few examples of open-source tools that can be used to detect unusual login activity. It's important to choose a solution that fits your organization's specific security needs and to thoroughly test and evaluate it before deploying it.

如何自動化偵測異常登入

自动检测异常登录的方法如下:

监控系统日志:定期检查系统日志,以查看登录活动的异常情况。

使用访问管理系统:使用访问管理系统(如IAM)来监控帐户的登录行为,并在发现异常情况时发送通知。

使用身份验证服务:使用身份验证服务(如MFA)来确保每次登录都是合法的。

使用安全信息与事件管理(SIEM)系统:使用SIEM系统来分析日志数据,以识别异常的登录行为。

使用人工智能(AI)和机器学习(ML)技术:使用AI和ML技术来分析登录数据,以识别异常的登录行为。

这些技术的使用可以帮助提高系统的安全性,并自动识别异常的登录行为。

如何知道登入行為異常?

以下是确定登录行为异常的方法:

异常的地理位置:如果检测到帐户登录来自异常的地理位置,这可能是一种异常登录的信号。

异常的时间:如果检测到帐户登录的时间与正常时间不符,这也可能是异常登录的信号。

异常的设备:如果检测到帐户登录使用的设备与正常不符,这也可能是异常登录的信号。

异常的登录尝试:如果检测到帐户的登录尝试频率明显增加,这也可能是异常登录的信号。

密码不正确:如果帐户的登录密码不正确,这也可能是异常登录的信号。

最好的做法是使用强大的安全系统,如威胁情报平台,实时监测帐户的登录行为,并在发现异常时及时采取行动。

雙因素認證有可能被破解嗎?

 雙因素認證可以提高帳戶的安全性,但不是100%安全。以下是可能破解雙因素認證的情況:

短信或語音認證碼被劫持:駭客可以通過篡改手機碼來獲取認證碼,這種情況下,雙因素認證就無法提供安全保證。

使用不受信任的設備:如果使用不受信任的設備或網路,雙因素認證可能會被駭客破解。

使用不安全的雙因素認證應用程序:使用不安全的雙因素認證應用程序,如被篡改的手機應用程序,可能會被駭客破解。

因此,雖然雙因素認證是一种很好的安全措施,但也不是绝对安全的。最好的做法是使用安全且可靠的雙因素認證方案,並對網路安全進行定期監控和评估。

如何防止駭客橫向移動攻擊?

 以下是防止橫向移動攻擊的常用措施:

分層網路設計:使用分層網路設計,以限制駭客移動到敏感系統。

雙因素認證:強制使用雙因素認證,以防止駭客使用被盜的凭证。

資料管理:定期監控和分析網路上的資料流量,以便及早發現異常行為。

入侵偵測系統:使用入侵偵測系統(IDS)和入侵防范系統(IPS),以監控網路活動並立即偵測攻擊。

軟體更新:及时更新系统和应用程序,以防止利用已知漏洞的攻擊。

權限管理:實施严格的權限管理,以限制駭客的访问权限。

網路安全政策:制定明确的网络安全政策,并定期培训员工,以确保员工了解如何保护敏感信息。

這些措施可以幫助防止駭客橫向移動,但是您也需要定期監控和更新網路安全程序以保持安全。

使用密碼管理器安全嗎?

密码管理器,例如 1Password,可以提高密码安全,但是也有其他因素需要考虑:

数据加密:确保密码管理器使用高级加密算法加密数据,以防止数据被黑客窃取。

安全设置:确保您使用强密码和多因素身份验证(MFA)以保护您的账户。

公司安全记录:了解该公司的安全记录,看是否有过数据泄露或其他安全问题。

数据储存位置:了解数据是否储存在您信任的位置,以防止数据被泄露。

总的来说,使用密码管理器可以增加密码安全,但是您仍然需要采取其他安全措施以保护您的账户。

密碼多久更換一次才安全

 密码多久更换一次才能确保安全是一个有争议的问题,不同的安全专家可能有不同的意见。但一般来说,下列建议可以作为参考:

每90天更换一次密码:这是一个常见的推荐,旨在避免长期使用同一密码,从而降低被黑客攻击的风险。

使用密码管理器:密码管理器可以帮助您生成强密码并自动储存,因此您不需要频繁更换密码。

特定情况下更换密码:在发生安全事件(例如,数据泄露)或使用被盗账号后,应立即更换密码。

最重要的是,使用复杂、不容易猜测的密码,避免使用相同的密码或与您的个人信息有关的信息(例如生日)作为密码。

如何實施零信任架構

实施零信任架构的一般步骤如下:

身份验证:强制执行多重身份验证,包括用户名/密码、令牌、证书等。

数据分类:将数据分类为不同的保密级别,并且只有经过身份验证的用户才能访问特定级别的数据。

网络隔离:通过防火墙、VPN 等技术对内部网络和外部网络进行隔离,并且只允许经过严格认证的流量。

实时监测:实时监测网络活动,快速识别和响应任何潜在的威胁。

风险评估:定期评估网络安全风险,并采取必要的措施来防范威胁。

这些步骤需要通过现代安全技术,如身份管理、数据加密、防火墙等来实现。在实施零信任架构时,需要经常评估网络安全情况,并对其进行适当的更新和维护。

零信任架構是甚麼

Zero Trust is a cybersecurity concept where access to resources is granted only after stringent verification of the identity and context of the request. This approach assumes that all actors, internal and external, are untrusted by default, and verifies each request before granting access. It aims to provide enhanced security by reducing the attack surface and minimizing the potential damage from a successful breach.

零信任是一种网络安全概念,即在严格验证请求者身份和上下文后才允许访问资源。这种方法假设所有内部和外部参与者都是默认不可信的,并在授予访问权限前对每个请求进行验证。它的目的是通过减少攻击面并最大限度地减少成功侵入所造成的损害,提供更强的安全保障。