Skip to content
  • Please, do not advertise here. Thank You!

  • bash script - efficient ip address sort & deduplicate

    #!/bin/bash
    
    input_file="input.file"  # Set the input file here
    
    # Check if the input file exists
    if [ ! -f "$input_file" ]; then
        echo "Error: Input file '$input_file' does not exist."
        exit 1
    fi
    
    # Create a temporary file to store the sorted results
    temp_file="sorted_addresses.tmp"
    
    # Sort the IP addresses based on each octet and save to the temporary file
    sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n "$input_file" | uniq > "$temp_file"
    
    # Overwrite the original input file with the sorted and deduplicated data
    mv "$temp_file" "$input_file"
    Edited by Mr E
  • bash script - efficient separation of ip addresses up to var = lines_per_file for use in various firewalls.

    #!/bin/bash
    
    # Check if the input file exists
    input_file="WISE-report.txt"
    if [ ! -f "$input_file" ]; then
      echo "Input file not found: $input_file"
      exit 1
    fi
    
    # Make a copy of the input file to preserve its content
    cp "$input_file" "temp_bad_addresses.txt"
    
    # Initialize variables
    lines_per_file=5000
    file_count=1
    
    # Create the output directory if it doesn't exist
    output_dir="output"
    mkdir -p "$output_dir"
    
    # Process the input file in chunks of 5000 lines
    while [ -s "temp_bad_addresses.txt" ]; do
      chunk_file="mASS_ip_$file_count.txt"
      head -n $lines_per_file "temp_bad_addresses.txt" > "$output_dir/$chunk_file"
      file_count=$((file_count + 1))
      tail -n +$((lines_per_file + 1)) "temp_bad_addresses.txt" > "temp_bad_addresses.txt.tmp"
      mv "temp_bad_addresses.txt.tmp" "temp_bad_addresses.txt"
    done
    
    # Create the "mASS_Files" directory if it doesn't exist
    output_files_dir="mASS_Files"
    mkdir -p "$output_files_dir"
    
    # Copy the output files to "mASS_Files" directory
    mv "$output_dir"/* "$output_files_dir/"
    
    echo "Processing complete. $((file_count - 1)) output files copied to '$output_files_dir'."
    
    # Optionally, you can remove the temporary copy of the input file
    rm "temp_bad_addresses.txt"
    Edited by Mr E
  • Important: icmp, igmp, tcp, udp; allowed and all other protocols w/ 'no alerts' are denied.

    drop ip any any -> any any (msg:"proto-denied"; flowbits: noalert; ip_proto:!17; ip_proto:!6; ip_proto:!2; ip_proto:!1; classtype:bad-unknown; sid:1; rev:1;)

    regards Mr. E

  • Other security:

    Alpine Linux - Mozilla Firefox - AppArmor profile (STRICT)

    Mozilla Firefox - Apparmor Profile

    Alpine Linux - HexChat - AppArmor profile (Strict)

    HexChat - AppArmor Profile

  • License:

    THE DOCUMENT, INFORMATION AND DATA ON THIS PAGE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH ANYTHING ON THE PAGE.

    regards Mr. E

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment