Author: mark_user

  • Export a KeePass Master Key File

    Export a KeePass Master Key File

    To in increase security, you can require a KeePass to use both a key file and a password to open the database. This makes it technically, two factor authentication (2FA).

    Go to file > change Master password. Check the ‘Show expert options’

    Enter a new master password. Check the key file box. Select Create. When completed, save the key file to a secure location. Such as a USB stick with Drive letter G:

    Plug in the USB stick. Launch KeePass, enter the password, and make sure the “key file/provider:” is pointed at your USB stick. The database will now open.

    Finally, be sure to backup the key file to your backup location. External hard drive, cloud, etc. If the key file is ever lost. There is no way to ever open the database.

  • How to Command Respect from Others

    I saw a YouTube video on a Russian Mafia Don and he stated how to command respect from others. You have to follow a few simple rules. I liked the advice so much I am reproducing it here.

    Do not divide your attention, focus, look the person in the eye.

    Make decisions and stick to them.

    Listen first, speak second.

    Speak slowly.

  • Generic Outline for Writing a Policy or Procedure

    Generic Outline for Writing a Policy or Procedure

    Initial Thoughts

    Polices are global in nature. All company employee’s are expect to follow the guidelines. Examples of polices include: the Acceptable Use Policy (AUP), Memorandum of Understanding (MOU), or Bring Your Own Device (BYOD) to work. These a often generic guidelines that all employees must adhere to. On the other hand, procedures are typically at the department or team level. They are a step-by-step guide book. Many departments will have multiple Standard Operating Procedure (SOP) for a wide variety of topics.

    When writing either, they follow a general outline. Here is some generic language to get you started.

    General Outline

    1. Purpose – Define the purpose of the policy.

    2. Requirements – Why is this required? What standards are to be followed? PCI data security standard (PCI DSS)? What other Legal or regulatory rules apply?

    3. Definitions – Define any terms or definitions used in the document.

    4. Process & Procedure – Typically a flow chart. Also, what data is to be evaluated (input), what results are expected (output). Are any records created ? Any reports generated?

    5. Role Responsibilities – Who is to do what? Who is to use this procedure?

    7. Communication, Exceptions, & Sanctions – Who is this procedure to be communicated to? All employees? Who is exempt from following the policy? Who should they contact to get an exemption? What is the penalty if it is not followed?

    8. Document Control – Who is the owner of the document, how often is it reviewed (annually?), Revision history chart is needed.

    9. Appendix – A written copy of the PCI standards that the document references. A URL or other notes or documents.

  • Test your DNS Proxy using a PowerShell Script

    Test your DNS Proxy using a PowerShell Script

    Introduction

    Most company’s have a policy to block dangerous websites for employees. Pornography, hate, gambling, social media are all categories that should be blocked. Either, they are big time wasters, or may be required by law to be blocked.

    Although you may have your proxy turned on correctly, that does not mean the bill got paid. Usually, a proxy will default to open for all users. You may be asked by outside 3rd party auditor’s or a senior manager to provide proof that the DNS proxy is actually working and blocking non-approved content.

    The script

    This PowerShell script will run as the current logged on user and send an email with the results. It will print the email in HTML format and each URL that it tests will be color coded. Red means site was blocked, green for site was successfully accessed, and gray for error.

    You will need to provide a list of websites in text document with one URL per line. I have included one below, as an example.

    Save this file as a ‘websitelist.txt’ file.

  • Ping Multiple Hosts using PowerShell

    Ping Multiple Hosts using PowerShell

    Are you are working in a windows environment and need to check if a large number of hosts are online? The below ps1 script may be what you are looking for. Place all hostnames to be checked in a text file called computer.txt and on one per line. Modify the script as necessary, then ‘run’ .

  • Backup Files to S3 using Bash

    Backup Files to S3 using Bash

    Description

    A bash script will be used to copy a file from a Linux server to an S3 bucket. Next, it will run a checksum on the results to verify the upload. Finally, it will output the local file size, the local etag , the aws file size, and the aws etag value for easy comparison. This should give the end user enough confidence that the uploaded file has maintained it’s integrity.

    The script assumes you have an account in AWS with a login credentials. You have the cli AWS tools and credentials downloaded to /home/user/.aws/config and /home/user/.aws/credentials. These two files are needed to successfully authenticate to the s3 bucket.

    Amazon Web Service S3 Bucket

    AWS is a flat file system. There are no folders or directories. The “full” name of a file includes all the subdirectories as well. i.e. “/file1/file2/file3.txt” is the file name and not “file3.txt”. AWS will show all subdirectories as folders in the console, for ease of human navigate.

    Begin

    Start the script by defining that it will run as bash and add any notes to the head.

    Send any log output to a custom log file and code to exit the script if any commands in a pipeline fails.

    Get the number of processing units available and add it to a variable.

    Define the remaining local variables.

    Define the AWS variables.

    When a file is uploaded to AWS, it will calculate what is called an ETAG value. This is the checksum value of the upload file. To verify file integrity, we will compare the uploaded aws calculated ETAG against the local file’s calculated ETAG.

    The ETAG will match a true md5 hash value if the file size is < 5 GB. If the file is > 5 GB, the aws ‘cp’ command will automatically break the file into 8 MB chunks and upload 4 threads of data simultaneously, until the upload is complete. Each uploaded thread will have an md5 calculated. The resulting ETAG will be a sum of all the uploaded data chunks, rather than a true md5 hash against the completed file.

    In order to compare the ETAG’s and verify they match, we must calculate the local file’s ETAG value. Then compare that value to the value calculated by AWS. The script contains two methods to calculate the ETAG value, you will need to review and consider what is needed. In my case, I always know the value I will upload will be > 5 GB.

    To calculate the local files ETAG value, for files < 5GB. use:

    For files > 5 GB, we can use the code from https://gist.github.com/rajivnarayan/1a8e5f2b6783701e0b3717dbcfd324ba.

    Next, we will copy the files to the s3 bucket using the ‘cp’ command. We will be using the CLI copy command, rather than the s3api command, as the api can not handle file’s large then 5 GB. Copy the content to S3 and tell AWS that the data is just a plain text file.

    Get the ETAG value that AWS calculated during the upload.

    Next, we will get both the local file size and the uploaded file sizes.

    Finally, display the file sizes and the ETAG values of both the uploaded file and the local file side by side for comparison.