4/16/2024

some useful tools from community - pictures

 













2/17/2024

About infosec clickjacking prevention methods and potential risks examples


There are several ways to test if your website is secure from clickjacking attacks. Here are three methods you can use:


Manual Testing:


Visual Inspection: Carefully examine your website for any invisible or disguised elements that could overlay legitimate buttons or links. Pay close attention to areas where users might potentially click, like login buttons, payment options, or download links.


Right-Click Testing: Try right-clicking on various elements of your website. If some elements don't respond to a right-click, they might be part of a hidden layer used for clickjacking.


Browser Developer Tools: Use your browser's developer tools to inspect the HTML structure of your website. Look for any suspicious nested layers or iframes that could be used to mask malicious elements.


Automated Testing:


Online Tools: Several online tools like Clickjacking Test (https://clickjacker.io/) and Clickjacking Vulnerability Tester ([[invalid URL removed]]([invalid URL removed])) allow you to scan your website for potential clickjacking vulnerabilities.


Security Scanners: Comprehensive website security scanners like Acunetix, Netsparker, and Burp Suite offer modules specifically designed to detect clickjacking vulnerabilities. These tools can provide more in-depth analysis and identify complex attack vectors.


Important Points:


Manual testing is good for a basic check, but automated tools can provide more comprehensive results.

Testing should be done on different browsers and devices to ensure consistent security.

Even if your website passes these tests, it's crucial to implement clickjacking prevention techniques.

Here are some common clickjacking prevention techniques:


Use the X-Frame-Options header: This header instructs browsers how to handle your website within an iframe. Set it to "SAMEORIGIN" to prevent loading your site in any other domain's iframe.

Enable Content Security Policy (CSP): CSP allows you to define specific policies for how resources like scripts and images can be loaded on your website. This can help prevent attackers from injecting malicious code that could be used for clickjacking.

Minimize the use of iframes: If you do use iframes, ensure they have clear purposes and proper security measures in place.

Remember, website security is an ongoing process. Regularly testing your website for vulnerabilities and implementing appropriate mitigation strategies is crucial to protect your users and data.



Examples of how iframes can cause security problems:

1. Clickjacking:


Scenario: An attacker embeds your website containing sensitive actions (like login or payment) within an invisible iframe on a malicious website. When the user clicks anywhere on the malicious website, they unknowingly click on the invisible iframe, triggering the sensitive action on your site without their knowledge or consent.

Impact: Stolen credentials, unauthorized transactions, compromised accounts.

2. Cross-Site Scripting (XSS):


Scenario: An attacker exploits a vulnerability on your website to inject malicious scripts into an iframe loaded from an untrusted source. These scripts can then access and steal sensitive information from your users' sessions or redirect them to phishing sites.

Impact: Data theft, session hijacking, malware downloads.

3. Clickjacking and Phishing:


Scenario: An attacker creates a fake login page that resembles your website and embeds it within an iframe on a malicious website. When the user clicks on the iframe, they think they're logging in to your site, but their credentials are sent to the attacker instead.

Impact: Stolen login credentials, account takeover, identity theft.

4. Denial-of-Service (DoS):


Scenario: An attacker embeds a resource-intensive webpage within an iframe on your website. When many users visit your site, the iframes overload their browsers, causing DoS attacks and impacting your website's performance.

Impact: Website unavailable or slow, loss of user trust, potential revenue loss.

5. Content Sniffing:


Scenario: An attacker uses an iframe loaded from their server to access and capture sensitive information like form data submitted on your website.

Impact: Stolen credit card information, personal details, leaked internal data.

These are just a few examples, and the specific risks depend on how you implement and use iframes.


Remember:


Always trust the source of the content loaded in the iframe.

Use the X-Frame-Options header to control how your website can be embedded.

Implement Content Security Policy (CSP) to restrict script execution and resource loading.

Minimize the use of iframes, especially for sensitive actions.

Regularly test your website for vulnerabilities and update your software.

By taking these precautions, you can minimize the security risks associated with using iframes.

1/18/2024

How to disable powershell on win11 by using bat script

 @echo off


reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun" /v 1 /t REG_SZ /d "powershell.exe" /f


echo PowerShell has been disabled.

pause


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技术来分析登录数据,以识别异常的登录行为。

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

如何知道登入行為異常?

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

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

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

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

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

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

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