secopsdev

repository·master·Indexed 19 days ago

https://github.com/weiyigeek/secopsdev

A repository focused on Security Operations (SecOps) development, providing scripts and tools for security automation and operations. It includes security hardening toolsets for CentOS 7, Ubuntu 22.04/20.04 LTS, and Windows Server 2019/Windows 10, as well as utilities for website monitoring with PhantomJS, automated FTP backups via PowerShell, and a Travelcodeocr API using EasyOCR.

Tokens
6.6K
Snippets
21
Records
32
Agent score
66%

What's inside secopsdev

  1. What is PhantomJS and its use cases

    master

    PhantomJS is a headless (no GUI) JavaScript API based on the WebKit library. It allows you to run standard DOM scripts and CSS selectors as if you were using a web browser, making it a lightweight, open-source solution for automating web browser operations.

    Key Capabilities:

    • Web Standards Support: DOM manipulation, CSS selectors, JSON, Canvas, and SVG.
    • Automation Tasks: Testing dynamic content (like AJAX), capturing screenshots, converting pages to PDF or prototypes, and executing cross-browser JavaScript tests.
    • Network & System Simulation: Simulating network latency, automating page visits, capturing network script errors/warnings, and performing file I/O operations (reading/writing files to the OS).
    • Platforms: Runs on Windows, macOS, Linux, and FreeBSD.
  2. Overview of CentOS 7 Security Hardening Tools

    master
    This toolset is designed for the security hardening and system initialization of CentOS 7 operating systems. The tools are provided as individual scripts that must be called manually based on your specific requirements. The suite covers network configuration, software management, time/timezone settings, security hardening (compliant with Level 3 protection requirements), system optimization, and disk management.
  3. Call specific hardening functions via --function

    master

    The tool is modular. While --start runs the full suite, you can execute individual hardening tasks by passing the function name to the --function flag.

    Commonly used functions include:

    System Base & Optimization:

    • base_hostname: Set the system hostname.
    • ubuntu_mirror: Configure Ubuntu software repository mirrors.
    • base_timezone: Synchronize time and set the timezone.
    • optimize_kernel: Optimize system kernel parameters.
    • resources_limits: Optimize system file descriptor limits.
    • swap_partition: Create a system swap partition.

    Security Hardening:

    • sec_usercheck: Lock or delete redundant system accounts.
    • sec_passpolicy: Set user password complexity policies.
    • sec_sshdpolicy: Configure SSHD service security policies.
    • sec_firewallpolicy: Configure system firewall policies.
    • sec_grubpolicy: Secure the GRUB menu to prevent unauthorized physical access.
    • sec_privilegepolicy: Set sudo permissions and directory creation policies.

    Network & Services:

    • net_config: Set host IP address and gateway.
    • net_dns: Set host DNS resolution servers.
    • svc_snapd: Disable or uninstall snapd services.
    • svc_cloud-init: Disable or uninstall cloud-init services.

    Software Installation:

    • install_docker: Install the latest version of Docker.
    • install_cockercompose: Install the latest version of Docker Compose.
  4. Windows Server Security Configuration Baseline Items

    master

    The hardening tools cover the following security configuration areas:

    • System Account Policies: Managing user accounts and authentication security.
    • System Event Auditing Policies: Configuring audit logs for security monitoring.
    • System Group Policy Security Options: Hardening system settings via Group Policy.
    • Registry Security Policies: Securing critical system registry keys.
    • Firewall Service Security Policies: Configuring firewall settings and services.
    • Manual Hardening Items: Addressing security gaps that cannot be configured via Registry or Group Policy.
    • Patch Compliance: Comparing the local installed security patches against the official Microsoft Security Update list.
  5. Monitor website changes using PhantomJS and Shell scripts

    master

    You can implement a website monitoring system that detects changes to a homepage, captures screenshots, and sends notifications (e.g., to Enterprise WeChat) to alert operations teams of potential hacking or hijacking risks.

    This implementation typically involves:

    1. A Shell script to orchestrate the process.
    2. PhantomJS to perform the actual web automation and screenshotting.
    3. crontab for scheduling periodic checks.

    Execution Example: After setting up the script and PhantomJS, you can execute the monitor manually or via cron. The script generates HTML snapshots, PNG screenshots, and JSON data files for comparison.

    # Make the monitoring script executable
    chmod +x /1.WebMonitorScreenCapture.sh
    
    # Run the monitoring script
    ./1.WebMonitorScreenCapture.sh
    
    # Check the generated logs and screenshots
    cd /var/log/WebScreenCapture/www.baidu.com
    ls
    # Expected output includes: 
    # index.html, index.html.png, data.json, exception.log, etc.
  6. Set up a Cloudflare Worker proxy for Gitalk

    master

    Gitalk requires a CORS proxy to interact with the GitHub API. You can use cloudflare-cors-anywhere to create an online proxy via a Cloudflare Worker.

    Important Security Note: The free tier of Cloudflare Workers has a limit of 100,000 requests per day. To prevent malicious users from exhausting your quota, you should implement an access whitelist when configuring your Worker. The implementation logic is based on the chrisspiegl/cloudflare-cors-anywhere repository.

  7. Automate data backup uploads to FTP using PowerShell

    master

    You can automate the process of uploading data backup files to an FTP server using PowerShell through three different methods, depending on your requirements for protocol support and dependencies:

    1. Windows Native FTP Client: Uses PowerShell in conjunction with the built-in Windows ftp command-line tool. Note that this method only supports Active Mode.

      • Script: DB-Backup-To-FTP.ps1
    2. .NET FtpWebRequest: Uses the built-in .NET class System.Net.FtpWebRequest within PowerShell. This is a more programmatic approach that does not rely on external CLI tools.

      • Script: DB-Backup-To-FTP-Use-Net.FtpWebRequest.ps1
    3. PSFTP Module: Uses the PSFTP PowerShell module to handle the connection and upload.

      • Script: DB-Backup-To-FTP-Use-PSFTP-Package.ps1

    Important Notes

    • Encoding: On Chinese Windows systems, PowerShell scripts default to GBK encoding. If you encounter garbled characters (mojibake), ensure you convert the script encoding to GBK or another appropriate encoding mode.