Author: dystrick

  • GTA SAO Workspaces

    GTA SAO Workspaces

    Problem
    The SAO Agency has contractors that are frequently on and off boarding. Due to SAO’s security policies, laptops with specialized tools and security configurations need to be deployed to these resources. There are 4-5 computer images, with 2-3 different hardware profiles to support all the specific needs the contractor roles may require. The time it takes to manage this hardware, get them imaged and shipped is time consuming, and increases the time to get the resources onboarded.

    Key Pain Points
    • Time and cost to on and offboard contractor resources
    • Ensuring security configurations and timely updates of tools
    • Hardware costs for keeping inventory up to date, fixing, and managing accessories
    • Having to have a number of different hardware models with different resources (CPU, RAM, HDD), where having unused inventory drives up cost

    Challenges
    Not having AWS expertise inhouse, the customer was unable to perform the necessary AWS configuration to stand up AWS Workspaces

    Solution
    We leveraged AWS WorkSpaces which offers a number of benefits to address their challenges:

    Scalability and Flexibility: WorkSpaces can easily scale up or down. We are able to quickly provision or deprovision desktops for the SAO contractors without significant upfront investments in hardware

    Security and Compliance: WorkSpaces prioritizes security. Data is stored centrally in the AWS cloud, reducing the risk of data loss from local devices. It supports encryption for data at rest and in transit. We connected Workspaces to SAO’s Active Directory Domain for user access control to ensure that SAO’s configured Group Policies are enforced on the desktop

    Cost Efficiency: With AWS WorkSpaces, you pay on a monthly basis for the number of WorkSpaces in use. This eliminates the need for large upfront hardware investments and reduces ongoing maintenance costs that SAO had been spending

    Centralized Management: SAO Administrators can manage WorkSpaces centrally through the Management Console. They can define user policies, allocate resources, and enforce security settings across multiple WorkSpaces, making it easier to maintain and control the desktop environment

    High Performance: WorkSpaces offers different instance types to cater to various performance requirements. We can tailor the appropriate hardware configurations for the contractors workload, ensuring smooth and responsive desktop experiences

    Overall, AWS WorkSpaces provided SAO with enhanced flexibility, security, scalability, and cost-efficiency, enabling

  • Setting up MFA with SNS and Java

    Setting up MFA with SNS and Java

    Rimpi Mathur | Technical Architect

    To provide better security and avoid unauthorized access to your applications, you should enable multi-factor authentication (MFA). This blog explains how to set up MFA using AWS APIs and services.

    What is MFA?

    With identity theft and cybercrime on the rise, multi-factor authentication (MFA) is a good way to improve your account security. MFA adds an additional layer of identity validation along with the basic login credentials. It is a unique number that is valid for a short duration of time and is sent to a device of your choice. This number is typically sent to an email address or cell phone number, but it can also be accessed using a specialty app.

    Technology

    We will be using the following technologies to achieve our goal.

    • • AWS SNS API
    • • Java 1.8 or higher
    • • Eclipse or any other IDE
    • • Maven for code build

     

    First, let’s look at sending MFA using the AWS admin console.

    Sending text message to cell phone using Amazon Simple Notification Service


    • • AWS Console Settings


    1.  Under “Simple Notification Service,” click on Test Messaging (SMS).
    2.  Make sure your account is not in the SMS sandbox; in sandbox mode, you can send a maximum of 10 text messages. Submit a request for Service Limit Increase. This normally takes a day to be approved by AWS.
    3.  From the console, purchase an origination number. This is a 10-digit toll-free number that will be used for sending out messages. This number is assigned by AWS.
    4.  To send a message from the console click on “Publish Text Message.”
      AWS SMS mobile text messaging  setup dialog box.
    5. Enter all the information in each box.
    Publish SMS message, Details in AWS console settings.
    Destination phone number
    Country-specific attributes, Entity ID, Template ID in Java.

    Now that we know how to send an MFA code from the console, let’s integrate this into our code.

    We will see how we can send the MFA code post-login from our codebase.

    Generate MFA code using Java

    There are many ways of creating a  6-digit number. One of the simplest ways is to use the Random() method in Java.


    • • Code for sending messages using SNS.


     

      1. We will import six packages that are required for defining the settings in AWS.

    com.amazonaws.regions.Regions;

    com.amazonaws.services.sns.AmazonSNSAsync;

    com.amazonaws.services.sns.AmazonSNSAsyncClientBuilder;

    com.amazonaws.services.sns.model.MessageAttributeValue;

    com.amazonaws.services.sns.model.PublishRequest;

    com.amazonaws.services.sns.model.PublishResult;

      1. Sample code for creating a text message.

    There are three AWS attributes that need to be set: region, maximum cost, and SMS type.

    public void sendSMS(String message, String phoneNumber) {

    // Initializes the message, phone number, aws attributes, and sends the code.

    try {

    PublishResult result = initSnsClient()
         .publish(new PublishRequest()
    .withMessage(message)
    .withPhoneNumber(phoneNumber)
    .withMessageAttributes(initSmsAttributes()));

    } catch (Exception e)

    }

    // The AWS region you will use for sending text messages; this region should be the same region that you moved to production mode (from sandbox) in the initial setting from AWS console.

    private AmazonSNSAsync initSnsClient() {

    AmazonSNSAsync snsClient =  AmazonSNSAsyncClientBuilder.standard()

    .withRegion(Regions.US_EAST_2).build();

    return snsClient;

    }

    // Sets the max price for sending each text message.

    private Map<String, MessageAttributeValue> initSmsAttributes() {

    if(smsAttributes == null) {

    smsAttributes = new HashMap<String, MessageAttributeValue>();

    smsAttributes.put(“AWS.SNS.SMS.MaxPrice”, new MessageAttributeValue()

    .withStringValue(“0.10″))

    .withDataType(“Number”));

    // Sets the type to Promotional (non-critical) or Transactional (message sent with high priority).

    smsAttributes.put(“AWS.SNS.SMS.SMSType”, new MessageAttributeValue()

    .withStringValue(“Transactional “))

    .withDataType(“String”));

    }

    return smsAttributes;

    }

        1. This code can easily be called from any other class for sending the text message.

        • • Sending MFA code using E-mail


    An e-mail can be sent using the helper class JmsTemplate

    private void addMessageToQueue(final Email email) {

    try {

        jmsTemplate.send(new MessageCreator() {

    @Override

    public Message createMessage(Session session) throws JMSException {

    return session.createObjectMessage(email);

    }

    });

    }

    catch (Exception e) {

    throw e;

    }

    }

    }

    Contact us for more help setting up MFA with SNS and Java!

     
  • Time to Be Trendy… What is Your Data Analysis Telling You?

    Time to Be Trendy… What is Your Data Analysis Telling You?

    William Phelps | Senior Technical Architect

    That tired old cliche of “time is money” is readily exemplified by looking at casinos and major retailers. Customers of both probably have never noticed that an accurate clock or other time device is not displayed in either type of establishment. Casinos typically have no windows either, as they really do not want the patrons to know how long they have been at the slots or sitting at the gaming tables. Big box stores and mass retailers have a slightly different game plan. Each store is meticulously laid out and optimized to entice customers to buy merchandise. For every minute over thirty minutes spent in a retail establishment, a consumer will spend $1 per that additional minute on average. This means that a customer that wanders around the store for 45 minutes will spend at least $15. But is that customer really wandering, or do they have a plan? If retailers cared to examine the data found on a simple cash register receipt, the retailer could (and would) know where exactly in the store that customer was looking, since they will know by the store layout design the general traffic pattern traversed by the customer throughout the store. By placing the biggest ticket items, like electronics, at the very back of the store, it’s ensured that every time a flat-screen TV is purchased, for example, the customer has been exposed to many smaller priced items on the journey between the TV display area and the exit. If the customer happens to buy snacks in addition to the TV, what else could a retailer place along a consistently traveled path by customers moving between point A (the TV) to point B (the snacks) that they might be enticed to buy? DVD endcaps, for example, could be placed on aisles between the two sections. Whatever the layout design choice is, it’s not by random chance. It’s done by using old-fashioned “numbers crunching,” today known by the trendier term “data analysis.” There are decisions made every day in every business where accurate and timely data analysis is crucial. The reasons may vary and can be very subjective, but the overarching reason is simple: to enable your worker (and by extension the business) to work both smarter and faster. In the example of the simple cash register receipt data, flow patterns and foot traffic count can be derived. In the case of a restaurant, receipting data may be useful to know that historically the dinner crowd comes in around 4:30 p.m., rather than the typically expected 6 p.m., and managers can staff accordingly. In the retailer example, maybe the kiosk worker giving out free yogurt samples should come later in the evening if foot traffic is heavier in the afternoon than in the morning. To paraphrase Mark Twain, “If you don’t look at the data, you are uninformed. If you simply read the data, you may be misinformed.” In a world of information overload, however, there is only a small amount of data analysis that can be reasonably consumed at a given time. It’s still prudent and necessary to use your time on gathering insights. These tidbits can come in via many avenues, where properly aggregated data can help identify crucial pinch points, such as:
    • • Do we have enough people to do the job at hand? Do we have too many people at the wrong time? How can we tell if we have the proper headcount?
    • • Advertising spends and returns on spend: Are we targeting the right audience? Are we spending in the right outlets? How do we know?
    • • Do we receive the full benefit of systems/processes that we have paid for? As an example, are we losing early discounts or other time-sensitive incentives, or are there other ways to measure return on investment accurately?
    In the case of information systems:
    • • Does our current infrastructure/ecosystem support projected volumes? What exactly is that volume projection? How can we come up with an educated number on actual system performance metrics?
    • • Are the current systems at or over capacity, or are they under-utilized? What metrics will tell us whether we need to scale up or scale down?
    • • Do we have systems or processes that should be sunsetted? Would that give rise to newer/different approaches?
    Sometimes it’s simply “knowing the unknown.” Can we spot trends or occurrences that may lead to either a desirable or undesirable outcome? The key is that a general direction could be derived through data analysis. It’s up to the reviewer to take an action (and whether the lack of action is still a viable option). Here are 8 Benefits of using document understanding to mine unstructured data. If time is truly money, isn’t it worth some time to look at the data that may be hiding in plain sight in server and application logs?

    Contact us for more help with data analysis!

  • Format JSON Data at Search Time

    Format JSON Data at Search Time

    By Forrest Lybarger | Splunk Consultant

    JSON data is a very common format in Splunk and users like to have control of the data. Splunk’s collection of json_* commands help users format JSON data at search time so that it can be presented and used without any permanent changes to the indexed data. This guide will help users learn how to use these commands themselves, so they can have full control of their JSON data. It is important to note that the commands are often looking for the name of a field containing a whole JSON event, so if the whole event is one JSON event then _raw can be used to reference the whole event as one field. First is the json_valid command. Using this command, strings can be validated as using proper JSON. It has simple syntax where you input the field containing the JSON data and it returns true or false. If you want to store the value in a field, you could use an if statement.
      • Example:
      • | eval valid = if(json_valid(_raw), 1, 0)
      • Result:
      • valid=1
    Second is json_array. This command lets you create an array with JSON formatting. You can use an array field or multi-value field in this command instead of hard coded values. This can be useful in cases like if you need a sub-search to return an array.
      • Example:
      • | eval array=json_array(field_name)
      • Result:
      • array=[“string1”, “string2″, “string3”]
    Third is json_object. This command creates JSON objects from the inputs given to the command. Other JSON commands can be used as inputs including another json_object command to create nested objects. The first input is just the name of the object, then you can add one more input that can be a nested JSON object, array, or hard-coded value.
      • Example:
      • | eval obj=json_object(“object1”, json_object(“object2”, json_array(“item1”, “item2”))
      • Result:
      • Obj={“object1”:{“object2”:[“item1″,”item2”]}}
    Lastly is json_extract. This command essentially lets you do a field extraction on the fly with JSON data. You just give the command the field containing the JSON data (if the event is one big JSON event, then do _raw) then tell it the path you want extracted.
      • Example:
      • | eval ext=json_extract(_raw, “array{0}”)
      • Event:
      • {
      •   “array”: [
      •     {
      •       “name”: “item1”,
      •       “subarray1”: [
      •         { “name”: “subitem1” },
      •         { “name”: “subitem2” }
      •       ]
      •     },
      •     {
      •       “name”: “item2”,
      •       “subarray2”: [
      •         { “name”: “subitem1” },
      •         { “name”: “subitem2” },
      •         { “name”: “subitem3” }
      •       ]
      •     },
      •     {
      •       “name”: “item3”,
      •       “subarray3”: [
      •         { “name”: “subitem1” },
      •         { “name”: “subitem2” }
      •       ]
      •     }
      •   ]
      • }
      •             Result:
      •             ext={“name”: “item1″,”subarray1”: [{ “name”: “subitem1” },{ “name”: “subitem2” }]}
    These commands are very useful for users that deal with a lot of web data or API related events. Some notable data that these commands could be useful for are AWS Cloudtrail events. Users might want to extract whole arrays as fields or do other JSON manipulation and these commands make all that possible within Splunk’s search bar.
  • How VMware vCenter UUID Duplicate ID Misconfiguration Can Affect the AWS CloudEndure and Elastic Disaster Recovery Solution

    How VMware vCenter UUID Duplicate ID Misconfiguration Can Affect the AWS CloudEndure and Elastic Disaster Recovery Solution

    By: Brandon Prasnicki, Technical Architect and Gabriel Zabal, Cloud & Cybersecurity Consultant

    What is CloudEndure and Elastic Disaster Recovery (EDR)?

    AWS CloudEndure from Amazon Web Services and AWS Elastic Disaster Recovery are both Disaster Recovery solutions that continuously replicate your machines (including operating system, system state configuration, databases, applications, and files) into a low-cost staging area in your target AWS account and preferred Region. While the AWS Elastic Disaster Recovery is the preferred solution moving forward, only CloudEndure was available in the AWS region in the configured Customer AWS region at the time of this particular project and writing of this article.

    In the case of a disaster, you can instruct CloudEndure Disaster Recovery to automatically launch thousands of your machines in their fully provisioned state in minutes.

    By replicating your machines into a low-cost staging area while still being able to launch fully provisioned machines within minutes, CloudEndure Disaster Recovery can significantly reduce the cost of your disaster recovery infrastructure.

    You can use CloudEndure Disaster Recovery and AWS Elastic Disaster Recovery Solution to protect your most critical databases, including Oracle, MySQL, and SQL Server, as well as enterprise applications such as SAP.

    The Issue
    Recently during a CloudEndure implementation, an odd behavior was observed in the CloudEndure console. The customer source environment was VMware vCenter and when machines would begin replicating and were showing replication status in a list, the servers would suddenly disappear from the list. Then in a short period of time, they would suddenly reappear. While this project was using CloudEndure, it is very likely this issue would also be seen in the new AWS Elastic Disaster Recovery solution as the agent and replication design is very similar.

    Screenshot of the AWS CloudEndure interface showing a list of machines under the "Machines" tab. All machines have their data replication status marked as "Data Replication Stopped" and "Not Ready." A red arrow points to one instance labeled "Machine reappears."

    The CloudEndure console provides Event Logging, and in this case, the logging was very helpful. Below you can see a message stating that the hardware on the machine changed. No hardware changes were anticipated, and certainly not this frequently.

    Screenshot of the AWS CloudEndure Event Log, displaying a list of hardware and private IP changes. The logs show repeated UUID and IP address changes for multiple source machines, indicating hardware re-identification issues due to VMware vCenter UUID duplication.

    After some internet research, it seemed likely that this behavior was due to duplicate UUIDs in the VMware vCenter environment. The CloudEndure Agent generates an ID upon installation based on the Hardware ID, and in the case of the VMware virtual machines, this ID is based on the UUID. This leads to having different Agents with the same ID.

    This issue is likely due to cloning configuration and not instructing VMware cloud director to create new UUIDs when using a vApp Template. This VMware KB mentions that when you use VMware Cloud Director, all virtual machines that are created from a vApp Template receive the same VM UUID.

    To confirm, these commands were run on the various hosts:

    c:wmic bios get name,serialnumber,version

    c:wmic csproduct get name,identifyingnumber,uuid

    Once the problem machines were identified, the fix to the CloudEndure agents was as follows:

    1.     Uninstall The CloudEndure Agent:

             Windows 64-bit
    • Copy the following folder to a new location:
    • C:Program Files (x86)CloudEnduredist
    • From the new location, run in CMD as an administrator:
    • install_agent_windows.exe –remove
             Windows 32-bit
    • Copy the following folder to a new location:
    • C:Program FilesCloudEnduredist
    • From the new location, run in CMD as an administrator.
    • install_agent_windows.exe –remove
             Uninstalling an Agent from a Linux Target machine:
    • Run as root or with sudo the following commands:
    • /var/lib/cloudendure/stopAgent.sh
    • /var/lib/cloudendure/install_agent –remove

    2.     Re-install the CloudEndure Agent using the steps from the Cloud Endure documentation found here:

    https://docs.cloudendure.com/Content/Installing_the_CloudEndure_Agents/Installing_the_Agents/Installing_the_Agents.htm

     

    Screenshot of a machine detail view in AWS CloudEndure, showing data replication as stopped. The right pane displays system specs, including CPU types, OS (Windows Server 2019 Datacenter), disk info, and a list of installed software packages, emphasizing the complexity of replicated environments.

    After re-installation, verify the ID is a unique value per machine:

    For references see:

    https://communities.vmware.com/t5/VMware-vSphere-Discussions/Retriev-the-UUID-of-a-VM-form-the-guest/td-p/976322
    https://communities.vmware.com/t5/VMware-Fusion-Discussions/cloned-VM-has-the-same-hardware-UUID/td-p/1343597
  • Restricting SFTP Access

    Restricting SFTP Access

    By: Stuart Arnett  | Principal Architect

     

    SFTP provides a mechanism to authenticate and transfer files securely between servers. It also allows authentication using SSH keys instead of username and password authentication. Using SSH keys is considered a better security practice for authentication because they are more difficult to hack with brute force. SFTP also simplifies firewall and network configuration because it only requires a single port to be opened to access the server.

    Using SFTP on a server does have some security concerns:

    • – The out-of-the-box configuration when setting up a Linux server allows users to access the server both via SSH and SFTP.
    • – Individuals using SFTP have access to system files that could be a security concern. (ex., /etc/passwd).
    • – Users could access files uploaded by other users if the correct folder/file system permissions are not specified when uploading files.

    This tutorial will walk you through how to set up a Linux server to provide the following functionality:

    • – Restrict which users can SSH into the server and which users can only access the server using SFTP.
    • – Restrict the SFTP users to a specific folder and sub-folders, eliminating the possibility of accessing files they shouldn’t see.
    • – Configure the permissions required for an admin user to have access to all the files uploaded via SFTP users and be able to share files with the SFTP users which can then be downloaded.

    Setting Up the Demo Environment

    We will be using the following for setting up the demo:

    • Operating System: Amazon Linux 2
    • SFTP Server: OpenSSH Secure Shell Daemon (SSHD)

    Group Setup

    A new group will need to be added to the server to allow admin user(s) to access the files uploaded by any of the SFTP users and to allow admin user(s) to add files to the SFTP user’s download folders.

    • groupadd sftp-admin

    User Account Setup

    We will add three users to the server:

    • – sftpadmin – Admin user with access to all the files uploaded by the SFTP users with the ability to also add files to the SFTP users’ download folders. The sftpadmin user won’t be able to access the server using SSH or SFTP, but the account can be accessed using sudo.
    • – sftpuser1 – User will only have SFTP access to the server and can upload and download files from their respective sftp sub-folders.
    • – sftpuser2 – User will only have SFTP access and can upload and download files from their respective sftp sub-folders.
    • adduser sftpadmin
    • usermod -a -G sftp-admin sftpadmin
    •  
    • adduser sftpuser1
    • adduser sftpuser2

    Configure the SSH keys for authentication for each of the new SFTP user accounts:

    • sudo su – sftpuser1
    •  
    • ssh-keygen
    •  
    • cd .ssh
    • mv id_rsa.pub authorized_keys
    • chmod u+rw-x,g-rwx,o-rwx authorized_keys
    •  
    • # Copy the private key located in the id_rsa file and store it in a protected
    • # location. It will be required for accessing the server later.
    •  
    • rm id_rsa
    • exit

    Repeat the above commands for sftpuser2.

    Configure the /sbin/nologin shell for the SFTP users to restrict SSH access to the server:

    • usermod -s /sbin/nologin sftpuser1
    • usermod -s /sbin/nologin sftpuser2

    SFTP Folders Setup

    A new SFTP folder and SFTP user sub-folders will need to be created to allow the correct permissions to be applied to allow admin users access to the SFTP user folders and restrict the SFTP users to only be able to access their own folders.

    • mkdir /sftp
    • chgrp sftp-admin /sftp
    • chmod u+rwx,g+rxs-w,o+rx-w /sftp
    •  
    • cd /sftp
    •  
    • mkdir sftpuser1
    • cd sftpuser1
    • mkdir download upload
    • chown sftpuser1 download upload
    • chmod u+rwx,g+rwxs,o-rwx download upload
    • cd ..
    •  
    • mkdir sftpuser2
    • cd sftpuser2
    • mkdir download upload
    • chown sftpuser2 download upload
    • chmod u+rwx,g+rwxs,o-rwx download upload

    The /sftp folder must be owned by root and the group and other permissions both need read and execute permissions on the folder. Setting the group to sftp-admin provides the necessary permissions required for the sftpadmin user to be able to access the folder. Group permissions also include the setuid bit which will preserve the sftp-admin group on any sub-folders created in the sftp folder. The following image depicts the correct permissions and ownership required for the /sftp folder:

    Correct correct permissions and ownership required for the /sftp folder: rwxr-sr-x 4 root stfp-admin 4- NOV 1 16:32 sftp.

    The SFTP user folder names (sftpuser1 and sftpuser2) need to match the usernames of the actual users. The folders need to also be owned by root with read and execute permissions for the group and others. The following image depicts the correct permissions and ownership required for the SFTP user folders:

    Correct permissions and ownership required for the SFTP user folders: drwxr-sr-x 3 root sftp-admin 16 Nov 1 15:39 sftpuser1 and drwxr-sr-x 4 root sftp-admin 36 Nov 1 16:34 sftpuser2.

    The download and upload folders need to be owned by the individual user that will be using the folders to provide them access to the folders. The group needs to be set to sftp-admin to provide access to the sftpadmin user. Both the user and group should have read, write, and execute permissions configured. The following image depicts the correct permissions and ownership required for the sftpuser1 download and upload folders:

    Correct permissions and ownership required for the sftpuser1 download and upload folders: drwxrws---2 sftpuser1 sftp-admin 6 Nov 1 18:30 download and drwxrws---2 sftpuser1 sftp-admin 6 Nov 1 18:30 upload.

    SSHD Configuration

    SSHD will need to be configured to restrict which users can SSH into the server vs. the users you only want using SFTP.

    • # backup the existing ssh_config file
    • cp /etc/ssh/ssh_config /etc/ssh/ssh_config.original
    •  
    • vi /etc/ssh/ssh_config

    Comment out the following line because we will be using the internal-sftp subsystem:

    Subsystem sftp /usr/libexec/openssh/sftp-server

    Add the following at the end of the configuration file:

    Subsystem sftp internal-sftp

     

    # Force all users except the ec2-user to use SFTP

    Match User *,!ec2-user

    • ChrootDirectory /sftp/%u
    • ForceCommand internal-sftp -u 0002
    • X11Forwarding no
    • AllowTcpForwarding no

    The above configuration forces all users to only be able to use SFTP except the “ec2-user.” The “ec2-user” will be able to use SSH and SFTP. When using SFTP, the ec2-user will start in their home folder (/home/ec2-user) and all other users will be restricted to /sftp/ folder and sub-folders. The following is a breakdown of each configuration line:

    • – “Subsystem sftp internal-sftp” specifies to use the SFTP process that is built-in to the SSH daemon and simplifies using the ChrootDirectory directive since it doesn’t require any additional support files.
    • – “Match User *,!ec2-user” will match all users except “ec2-user” and use the indented directives specified after the match line.
    • – “ChrootDirectory /sftp/%u” will restrict all SFTP users to the /sftp/ folder and sub-folders.
    • – “ForceCommand internal-sftp -u 0002” forces the use of the built-in SFTP process and configures the umask to 0002 during the SFTP session.
    • – “X11Forwarding no” line prevents SFTP users from forwarding X sessions.
    • – “AllowTcpForwarding no” line prevents SFTP users from forwarding TCP ports.

    Restart the SSH daemon to use the new configuration:

    • systemctl restart sshd

    Testing

    Create some test files in the SFTP user’s download folders:

    • sudo su – sftpadmin
    •  
    • cd /sftp/sftpuser1/download
    • touch user1-test1.txt user1-test2.txt user1-test3.txt
    •  
    • cd /sftp/sftpuser2/download
    • touch user2-test1.txt user2-test2.txt user2-test3.txt

    All the following tests should pass successfully:

    1. Verify the ec2-user can open an SSH session to the server.
    2. Verify the ec2-user can open an SFTP session and is placed in the /home/ec2-user folder.
    3. Verify the sftpuser1 and sftpuser2 users cannot open an SSH session successfully.
    4. Verify the sftpuser1 and sftpuser2 users can open an SFTP session.
    5. Verify the sftpuser1 and sftpuser2 users only have access to the upload and download folders and can’t navigate anywhere else on the filesystem.
    6. Verify the sftpuser1 user sees the user1-*.txt files in the download folder and can successfully download and delete the files.
    7. Verify the sftpuser2 user sees the user2-*.txt files in the download folder and can successfully download and delete the files.
    8. Verify the sftpuser1 and sftpuser2 users can upload some test files into the upload folder.
    9. Verify the sftpadmin user can access the files in the SFTP user’s upload folders and delete the files.

    You now have successfully configured SFTP to restrict who can access the server using SSH and/or SFTP. Users that are restricted to SFTP-only access are limited to which folders they can access on the server, eliminating the possibility of someone accessing system files or other files. Users associated with the sftp-admin group can access any files uploaded by the SFTP users, eliminating the need to have root privileges to access the files. Any new users added to the server won’t have SSH or SFTP access by default unless they are set up and configured correctly.

    Contact us for more help on restricting SFTP access!

  • Monitoring Windows Event Logs in Splunk

    Monitoring Windows Event Logs in Splunk

    By: Karl Cepull  | Senior Director, Operational Intelligence

     

    Splunk is a widely accepted tool for log aggregation and analysis in both security and IT Ops use cases. Splunk’s add-ons for Microsoft Windows, including Exchange and Active Directory, rely on Windows Event Logs being available and a forwarder used to send those logs into Splunk. Windows logs provide a wealth of information with every action taken. The problem is the volume of information available means ingesting a large amount of non-relevant data into Splunk. Looking at a couple of general use cases, here is a list of Windows Event IDs to add when looking for specific information.

    Use Case 1: Security

    Windows Security can include several of the other use cases listed below. These are Event IDs that indicate suspicious or unusual activity.

    EventIDPriorityDescriptionSub-Codes
    1102HighThe audit log was cleared. Probably want to investigate why. 
    4767HighAccount Unlocked 
    4740HighAccount Locked Out 
    4771HighKerberos pre-authentication failed 
    4772HighA Kerberos authentication ticket request failed 
    4820HighKerberos Ticket-Granting-Ticket was denied because the device does not meet the access control restrictions.0x12 (account disabled), 0x18 (bad password), 0x6 (bad username)
    4625HighLogon Failure. Sub-codes begin with 0xC00000.64 (user doesn’t exist), 6A (bad password), 234 (user currently locked out), 72 (account disabled), 6F (logon outside of permitted times), 193 (account expiration)
    4719MediumSystem audit policy was changed. 
    4728MediumA user was added to a privileged global group 
    4732HighA user was added to a privileged local group 
    4756HighA user was added to a privileged universal group 
    4782HighPassword hash an account was accessed 

    Use Case 2: IT Operations

    While there are several different Event IDs to monitor for all aspects of IT Operations, a few important ones are listed here. These are events a system administration should pay special attention to.

    EventIDPriorityDescription
    1101MediumAudit events have been dropped by transport. Possibly dirty shutdown.
    1104HighThe security log is now full. There will be holes in your logs if not fixed.
    4616HighSystem time was changed.
    4657HighA registry value was changed.
    4697MediumAn attempt was made to install a service.

    Use Case 3: Monitor User Accounts

    A typical user may appear in Windows logs for logging on and off a system. Other user account events should not appear regularly for any one user. Without a larger planned event, where planned account activity is occurring, most of these Event IDs should remain low. Log-on and log-off events are listed here as low priority. Others are higher.

    EventIDPriorityDescription
    4720HighUser account created
    4723MediumUser changed own password
    4724MediumPrivileged user changed their password
    4725HighAccount disabled
    4738HighAccount changed
    4726HighAccount deleted
    4781MediumAccount name changed
    4624LowSuccessful logon
    4647LowUser-initiated logoff

    Use Case 4: Scheduled Tasks

    In a recent security scare, the threat was seen creating scheduled tasks to perform actions that compromised data security. Like all other actions, scheduled tasks are logged in Windows Events, and can be added to Splunk.

    EventIDPriorityDescription
    4698MediumA scheduled task was created
    4699MediumA scheduled task was deleted
    4700MediumA scheduled task was enabled
    4701MediumA scheduled task was disabled
    4702MediumA scheduled task was updated

    Use Case 5: Windows Firewall

    Windows has a built-in firewall. While this may be disabled by system administrators, environments where the firewall is active can use the event logs to monitor for suspicious activity. Unexpected and unauthorized rules and policies changes are strong indicators of threat, along with unapproved stopping of firewall services.

    EventIDPriorityDescription
    4946HighA rule was added to the Windows Firewall exception list
    4947HighA rule was modified in the Windows Firewall exception list
    4950MediumA setting was changed in Windows Firewall
    4954MediumGroup Policy settings for Windows Firewall was changed
    5025HighThe Windows Firewall service was stopped
    5031HighWindows Firewall blocked an application from accepting incoming traffic

    Use Case 6: Windows Filtering Platform

    Windows Filtering Platform is a set of API and system services that provide a platform for creating network filtering applications. It’s important to keep an eye on these events to make sure any unexpected or unapproved actions are captured.

    EventIDPriorityDescription
    5146HighThe Windows Filtering Platform has blocked a packet.
    5147HighA more restrictive Windows Filtering Platform filter has blocked a packet.
    5148HighThe Windows Filtering Platform has detected a DoS attack and entered a defensive mode; packets associated with this attack will be discarded.
    5149HighThe DoS attack has subsided and normal processing is being resumed.
    5150HighThe Windows Filtering Platform has blocked a packet.
    5151HighA more restrictive Windows Filtering Platform filter has blocked a packet.
    5152HighThe Windows Filtering Platform blocked a packet.
    5153HighA more restrictive Windows Filtering Platform filter has blocked a packet.
    5154MediumThe Windows Filtering Platform has permitted an application or service to listen on a port for incoming connections.
    5155HighThe Windows Filtering Platform has blocked an application or service from listening on a port for incoming connections.
    5156MediumThe Windows Filtering Platform has allowed a connection.
    5157HighThe Windows Filtering Platform has blocked a connection.
    5158MediumThe Windows Filtering Platform has permitted a bind to a local port.
    5159MediumThe Windows Filtering Platform has blocked a bind to a local port.
    5447HighA Windows Filtering Platform filter was changed.

    This is not an exhaustive list of Windows Event Codes, nor is it a complete list for each use case. It’s a starting point for observation and can help to limit the number of events ingested by Splunk from Windows. Start by allowing the Event IDs listed above. As specific use cases develop, a deeper exploration of other Event IDs can help expand Splunk’s scope and effectiveness.

    Adding Event IDs to Splunk

    The easiest way to monitor Windows Event Logs in Splunk is to use the Splunk Add-On for Microsoft Windows. After installing the app, create a folder named “local” inside the app. Then, copy inputs.conf from the app’s “Default” folder and paste it in the local folder. Within each of the input stanzas, an allowed list can be added based on the pre-defined categories within the add-on.

    [WinEventLog://Application]

    disabled = 0

    start_from = oldest

    current_only = 0

    checkpointInterval = 5

    renderXml = true

    [WinEventLog://Security]

    disabled = 0

    start_from = oldest

    current_only = 0

    evt_resolve_ad_obj = 1

    checkpointInterval = 5

    blacklist1 = EventCode="4662" Message="Object Type:(?!s*groupPolicyContainer)"

    blacklist2 = EventCode="566" Message="Object Type:(?!s*groupPolicyContainer)"

    renderXml = true

    [WinEventLog://System]

    disabled = 0

    start_from = oldest

    current_only = 0

    checkpointInterval = 5

    renderXml = true

    Based on the use cases above, add the setting “whitelist=” to the stanza, followed by a comma-separated list of Event IDs. For example, to monitor “System,” use the IT Ops Event IDs. The stanza would then look like this:

    [WinEventLog://System]
    disabled = 0
    start_from = oldest
    current_only = 0
    checkpointInterval = 5
    renderXml = true
    whitelist = 1101, 1104, 4616, 4657, 4697

    The same can be done with the other input stanzas for more comprehensive coverage of Windows Event Logs.

    Contact us for more tips and tricks on monitoring Windows Event Logs with Splunk!

  • Back to the Present: Fixing Incorrect Timestamps in Splunk

    Back to the Present: Fixing Incorrect Timestamps in Splunk

      By: Jay Young  | Senior Splunk Consultant

     

    It is not uncommon, in large and small Splunk Enterprise environments, to have events with future or past timestamps. With time being a critical component of Splunk, incorrect timestamps can severely impact the hot and warm buckets on the indexers; hot buckets may roll too early, before they meet the set size of the attribute maxDataSize(default size 750mb), creating non-uniform-sized warm buckets.

    The excellent news is that Splunk has added IndexAttributes in indexes.conf. These attributes are quarantinePastSecs and quarantineFutureSecs to support the inspection of time at the indexing tier. These two IndexAttributes help quarantine events to better manage the flow of time throughout all indexes.

    The quarantine constraints detect future and past events with varying degrees of time as they get indexed. If the indexers encounter events with timestamps that exceed these boundaries, it sends them to a separate hot bucket called the hot quarantine bucket; this bucket is located in the exact location as the primary hot bucket and is identified by “hot_quan_vx_xxx.”

    The quarantinePastSecs and quarantineFutureSecs both have default settings in Splunk and should not be altered in the default indexes.conf file; they do allow for control at the individual index level and can be adjusted to fit a single indexes allowable time range.

    The two Indexes.conf.IndexAttributes:

    • quarantinePastSecs = <positive integer>
    • quarantineFutureSecs = <positive integer>
    Splunk configuration diagram illustrating default settings for quarantineFutureSecs and quarantinePastSecs, set to 30 and 900 days respectively.

     

    By default, these two IndexAttributes are set at 30 days for quarantineFutureSecs and 900 Days for quarantinePastSecs. Both IndexAttributes’ accepted values are calculated in seconds. These values determine the range for acceptable future and past events.

    Common Issues That Cause Future and Past Timestamps

    1. Improperly configured attributes in props.conf.
    2. Having different timezone events sent to the indexers.
    3. Events are delayed and then get sent to the indexers.
    4. System turned off for extended period with no time server configured on bootup.
    5. When the time changes in the spring and fall, excluding Arizona. 😊

    How to Check for Future and Past Timestamps

    Example: This is a quick way to identify indexes with future or past timestamps.

    NameActionTypeAppCurrent SizeMax SizeEvent CountEarliest EventLastest Event
    mainEdit Delete DisableEventsSearch204 MB500 GB22.6kIn 3 monthsIn 13 hours

    Splunk > Settings > Indexes >

    The Lastest Event column in the Splunk Index administration page shown in the example above shows that events will be current time events “in 13 hours.” This means at this time, they are events in the future. For example: if the present time is midnight, then at 1 p.m., the events in the hot quarantine bucket would be eligible to roll to warm buckets as they have passed the present time of now; but until the time passes, the future events will be kept in the Hot Quarantine bucket on the indexer.

    The Earliest Event Column is the oldest event currently Indexed in the index.

    Example Queries:

    • Query for small environments: index=* earliest=+5m latest=+5y
    • Query for larger environments: index=(name) sourcetype=(name) earliest=+5m latest=+5y

    Understanding _indextime vs. _time the Parsed One

    In Splunk, there are two different times used. Events in Splunk are not generally received at the same time as indicated in the event timestamp; the difference is usually a few seconds from the indexer arrival time to the event timestamp. The actual arrival time is written to _indextime, and the timestamp embedded in the event is parsed and stored in _time. When searching in Splunk, 99.999% of the time you will be searching against the _time parsed from the event. Future and past timestamps would be tough to get in _indextime and would be a server date and time issue instead of event time issues.

    Example Query to find Indexing Latency:

    • index=(name) | eval time=_time | eval indextime=_indextime | eval latency=(indextime-time) | stats count by avg(latency), min(latency), max(latency) by sourcetype

    Bucket Naming Examples Normal and Future

    In the example below, the lastest timestamp is the newest event in the warm bucket; this can also be described as the last event to get indexed before the hot bucket rolls to warm. The earliest timestamp is the oldest in the warm bucket; this is the first event to go into the newly created hot bucket. When the hot bucket rolls, the warm bucket gets created, then gets appended with epoch timestamps to represent the two values, earliest and lastest.

    Epoch timestamp converter: https://www.epochconverter.com/

    Example: Normal warm bucket.

    EARLIEST TIMESTAMP1. DST Monday, August 16, 2021 11:42:24 AM GMT-05:00
                                                                                        1.earliest         2.Latest

    current warm bucket with epoch time — db_1629961138_1629132144_95

    LASTEST TIMESTAMP2. Thursday, August 26, 2021 1:58:58 AM GMT-05:00

    Example: What would happen if a future timestamped event is allowed to roll into a warm bucket?

    EARLIEST TIMESTAMP1. Tuesday, August 24, 2021 11:42:24 AM GMT-05:00 DST
                                                          1.earliest        2.latest

    current warm bucket — db_1756166400_1629823344_97

    LASTEST TIMESTAMP2. Tuesday, August 26, 2025 12:00:00 AM GMT-05:00 DST

    The above example is a warm bucket with a future timestamp rolled into it. This bucket now has a timestamp that is four years in the future. This future timestamp would cause this warm bucket to not roll into a cold bucket or be removed for four years plus the current retention policy. This type of future bucket would continuously be searched for the next four years, affecting search performance.

    Using Splunk without these two IndexAttributes would cause warm buckets to sit on the indexers waiting to age out until the present time pasted the Lastest event timestamp, causing it to be continuously searched from scheduled and ad-hoc searches due to the lastest time being in the future. If this process was allowed to continue, your Splunk indexers could potentially reach the default number of warm buckets (“maxWarmDBCount=300”) and have hundreds of warm buckets sitting on the indexers with data that should have aged out a long time ago.

    Indexes.conf indexAttribute reference:

    https://docs.splunk.com/Documentation/Splunk/latest/Admin/Indexesconf
    Splunk documentation explaining quarantineFutureSecs, which determines how far in the future an event's timestamp can be before it's quarantined, defaulting to 30 days.

    https://docs.splunk.com/Documentation/Splunk/latest/Admin/Indexesconf
    Splunk documentation describing quarantinePastSecs, defining how old an event can be before being quarantined, with a default of 900 days.

    Contact us for more help on managing your Splunk environment!

  • Splunk Deployer Push Modes and How to Use Them Properly

    Splunk Deployer Push Modes and How to Use Them Properly

      By: Karl Cepull  | Senior Director, Operational Intelligence

    What is Deployer Push Mode?

    A Splunk Deployer is used to send apps and configuration files to search head cluster members. Deployer push mode determines where the Splunk deployer pushes configuration bundles to in search head cluster members. As apps are pushed to any Splunk server, the location of the .conf files determines where they fall in the order of precedence loaded into Splunk. To review, configurations located in the local folder of an app outweigh the same configuration in the default folder. By default, the deployer uses “merge_to_default” as the mode. This means all configurations are pushed into the default folder. Existing local configurations will overwrite the same configurations in the default folder. The push mode applies to app directories, not user directories. Splunk deployer consists of four push modes: Full, Local_only, default_only, and merge_to_default.

    ModeDescription
    Full (full)–        This mode is used to push both /local/ and /default/ app directories to members.

    –        Do not use full mode for Splunk built-in apps

    –        Use this mode if you want to migrate apps from a single search head to a new search head cluster.

    –        This mode is used if you have a configuration on the deployer’s app’s /local directory you want to push to the members and have it deleted from the deployer.

    Local Only (local_only)–        This mode is used to push /local/ app directories to members and merges it to exists files/directories.

    –        This mode is used to modify only those apps that already exist on the members.

    –        This mode is to modify configuration for a built-in app in the /local directory, such as the search app

    Default Only (default_only)–        This mode is used to push /default/ and non /local/ app directories to the members.

    –        Use this mode if you prevent apps /local directory in the members from receiving configuration changes during a deployer push

    Merge to Default (merge_to_default)–        This mode is used to push all files from apps /local/ directory to corresponding apps in /default/ directory and also merges /default/ files to /default/ directories in each member.

    –        This mode is used if you have a configuration in the deployer’s apps /local that needs to be pushed to the members and deleted from the deployer.

    Set the Deployer Push Mode

    You can set the deployer mode to be global or app-specific. App-specific settings take precedence over global settings. Set the push mode globally if you want to have one global policy standard. Set the push mode to be app-specific if you want to target a particular app.

    Set the deployer push mode to be global or app-specific by configuring deployer_push_mode under the [shclustering] stanza in app.conf. App-specific settings take precedence over global settings.

    Example 1 (Global setting)

    $SPLUNK_HOME/etc/system/local/app.conf
    [shclustering]
    deployer_push_mode = full

    Example 2 (App-specific setting)
    $SPLUNK_HOME/etc/apps//local/app.conf
    [shclustering]
    deployer_push_mode = default_only

    Contact us for more help on Splunk Deployer Push Modes!

  • Query AWS Resources with a Custom Search Command in Splunk

    Query AWS Resources with a Custom Search Command in Splunk

    By: Bruce Johnson  | Director, Enterprise Security

    Ever wondered what to make of all those resources living in your Cloud environment? Perhaps you’ve asked yourself, “What if I could leverage data from my cloud environment to enhance day-to-day Splunk operations?” The purpose of this blog is to show you how to quickly create a Splunk custom search command that will allow you to query AWS resources on the fly. New capabilities, eh? Well, maybe not so new. Custom search commands have been supported by Splunk for many years now; we’ll simply be shedding some light on how you can easily enhance the functionality of your Splunk environment to meet your business needs.

    Splunk custom search commands are “commands that extend SPL to serve your specific needs.” Custom search commands can be Generating, Streaming, Transforming, and Dataset processing, each type serving a different purpose and functionality. For example, Generating search commands fetch data from a given location without performing any additional data processing or transformation. With a Splunk Generating search command, data can be natively fetched from a Splunk index or imported from any external source such as an API. In this blog, we’ll install a custom Splunk Generating Command that interacts with the AWS API to retrieve information about real-time compute and network resources deployed in a cloud environment.

    Other types of Splunk search commands:

    • – Streaming: process search results one-by-one, applying one transformation to each event that a search returns. A commonly used Splunk streaming command is the eval command.
    • – Dataset processing: require the entire dataset in place before the command can run. For example, the sort command is a Dataset processing command that sorts the returned results based on the defined search fields.
    • – Transforming: order search results into a data table. For example, chart, top, stats, time chart.

    This blog walks you through the steps of installing a custom Splunk Generating command that allow you to query real-time resource information from your AWS cloud environments such as EC2 Instances, EBS Volumes, Security Groups, Network Interfaces, Subnets, and VPCs. This custom Splunk Generating command uses the Splunk SDK to interact with the AWS API and imports data into Splunk for further event processing and correlation. This custom Splunk Generating command can be used to:

    • – Fetch information about existing AWS resources
    • – Create inventory lookups for AWS resources
    • – Correlate external data with Splunk indexed data

    Requirements:

    • – AWS account
    • – Splunk Search Head hosted on an EC2 Instance
    • – AWS IAM Role
    • – AWS IAM Policy
    • – Custom Search Command TA

    To keep the blog simple, we’ll assume that our readers have a Splunk installation already launched in AWS. This blog will walk through the process of creating the necessary AWS role and policy to ensure the EC2 instance has the required permissions to query AWS resources. Once that’s taken care of, we’ll install the custom search command TA onto the Splunk Search Head.

    Create AWS IAM Policy and Role:

    1. Log in to your AWS account via the AWS Management Console.
    2. Go to the IAM service.
      WS Management Console showing IAM service search results, highlighting identity and access management setup.
    3. Create an IAM Policy with the following AWS permissions.
      Screenshot of a JSON IAM policy configuration in AWS, granting permission to describe EC2 instances, network interfaces, VPCs, volumes, subnets and security groups.
    4. Create an IAM Role that inherits the IAM policy you created in step three.
      Screenshot of the AWS IAM role creation interface, step 2 of 4, showing a permissions policy named “custom_spl” selected, with part of its JSON definition visible below.
    5. Attach the IAM role created to your Splunk Search Head.
      Screenshot of the AWS EC2 console showing the "Modify IAM role" interface, with the instance ID selected and a dropdown menu assigning the IAM role named “custom_command_role_spl.”

    Install Custom Search Command on Splunk Search Head

    1. Initialize an SSH session to the Splunk Search Head.
    2. Clone the Custom Search Command repository from GitHub to $SPLUNK_HOME/etc/apps: git clone
    3. Restart Splunk: $SPLUNK_HOME/bin/splunk restart
    4. Search away!
    Splunk search results for AWS EC2 instance metadata, displaying JSON output with resource properties.

    EC2 Instances:

    Splunk dashboard showing subnet data pulled from AWS using a custom search command.

    Subnets:

    VPC resource attributes displayed in Splunk, retrieved via a custom AWS resource query.

    VPCs:

    Security group configurations shown in Splunk interface, queried through AWS integration.

    Security Groups:

    Volume details from AWS environment shown in Splunk search output, including attachment and state info.

    EBS Volumes:

     Interface metadata for AWS network components visualized in Splunk with structured fields.

    Network Interfaces:

    Terminal screenshot of file directory structure for a custom Splunk app, showing configuration and Python script files.

    TA Components:

    • – aws_resources.py: Defines the AWS Client and required functions to pull AWS resources
    • – awssearch.py: Defines the Splunk Generating Command used to pull AWS Resources
    • – splunklib: Splunk SDK Python modules
    • – commands.conf: Defines the “awssearch” SPL command to be used
    • – searchbng.conf: Defines search-assistant configurations for the “awssearch” SPL command

    Learn more about Splunk custom search commands.

    Contact us for more help on using custom search commands in Splunk!