This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Accept
Reject

NetWitness Community

  • Home
  • Products
    • NetWitness Platform
      • Advisories
      • Documentation
        • Platform Documentation
        • Known Issues
        • Security Fixes
        • Hardware Documentation
        • Threat Content
        • Unified Data Model
        • Videos
      • Downloads
      • Integrations
      • Knowledge Base
    • NetWitness Cloud SIEM
      • Advisories
      • Documentation
      • Knowledge Base
    • NetWitness Detect AI
      • Advisories
      • Documentation
      • Knowledge Base
    • NetWitness Investigator
    • NetWitness Orchestrator
      • Advisories
      • Documentation
      • Knowledge Base
      • Legacy NetWitness Orchestrator
        • Advisories
        • Documentation
  • Community
    • Blog
    • Discussions
    • Events
    • Idea Exchange
  • Support
    • Case Portal
      • Create New Case
      • View My Cases
      • View My Team's Cases
    • Community Support
      • Getting Started
      • News & Announcements
      • Community Support Forum
      • Community Support Articles
    • Product Life Cycle
    • Support Information
    • General Security Advisories
  • Training
    • Blog
    • Certification Program
    • Course Catalog
    • New Product Readiness
    • On-Demand Subscriptions
    • Student Resources
    • Upcoming Events
  • Technology Partners
  • Trust Center
Sign InRegister Now
cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for 
Search instead for 
Did you mean: 
NetWitness Discussions
  • NetWitness Community
  • Discussions
  • Sample Contents: detect unused accounts with the SAW
  • Options
    • Subscribe to RSS Feed
    • Mark Topic as New
    • Mark Topic as Read
    • Float this Topic for Current User
    • Bookmark
    • Subscribe
    • Mute
    • Printer Friendly Page

Sample Contents: detect unused accounts with the SAW

DavideVeneziano
DavideVeneziano Beginner
Beginner
Options
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

‎2014-12-16 09:44 AM

This articles follows up another example posted here a few days ago () and will be focused as well on how to use the Security Analytics Warehouse to generate advanced reports.

 

We are going to leverage once again the expert-mode and Hive as a query language to accomplish our objective that is detecting user accounts which have not been used for the last 7 days.

 

Also here the first step is to create an external table which is pointing to the location in our SAW which contains our data set, specified by the LOCATION directive containing the avro files (everything from November 2014).

We also need to define the schema, listing all the meta keys need for our query:

SET hive.mapred.supports.subdirectories=true;

SET mapred.input.dir.recursive=true;

DROP TABLE IF EXISTS AllSessions;

CREATE EXTERNAL TABLE AllSessions ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.avro.AvroSerDe' STORED AS INPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat' OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat' LOCATION '/rsasoc/v1/sessions/data/2014/11' TBLPROPERTIES ('avro.schema.literal'=' { "type":"record", "name":"nextgen", "fields": [

{"name":"user_src","type":["string","null"],"default":"null"},

{"name":"device_type","type":["string","null"],"default":"null"},

{"name":"time","type":["long","null"],"default":"null"},

{"name":"user_dst","type":["string","null"],"default":"null"} ] }');

We now want to create a temporary table storing for each username, the last time has been seen in our dataset.

DROP TABLE IF EXISTS Users;

CREATE TABLE Users (username string,lastSeen bigint);

 

Time now to populate the termporary table. To do so, we group our databa set by user_src and add for each username the greatest "time" meta (which is the time of the last event since it is a unix timestamp):

INSERT OVERWRITE TABLE Users SELECT user_src,MAX(time) from AllSessions GROUP BY user_src;

 

Then, if we want to extract all the accounts not used for the last 7 days, we just need to select from the temporary table the rows whose timestamp is less than the difference between now (UNIX_TIMESTAMP() returns the current timestamp in seconds) and the number of seconds elapsed in 7 days (7*24*3600😞

SELECT username,FROM_UNIXTIME(lastSeen) FROM Users WHERE lastSeen < UNIX_TIMESTAMP()-7*24*3600;

 

Also this full sample has been attached below.

 

Disclaimer: please DO NOT consider what is described and attached to this post as RSA official content. As any other unofficial material, it has to be tested in a controlled environment first and impacts have to be evaluated carefullybefore being promoted in production. Also note the content I publish is usually intended to prove a concept rather than being fully working in any environments. As such, handle it with care.

  • Community Thread
  • Discussion
  • Forum Thread
  • hive
  • NetWitness
  • NW
  • NWP
  • RSA NetWitness
  • RSA NetWitness Platform
  • SAW
Preview file
2 KB
0 Likes
Share
Reply
  • All forum topics
  • Previous Topic
  • Next Topic
0 REPLIES 0
Powered by Khoros
  • Blog
  • Events
  • Discussions
  • Idea Exchange
  • Knowledge Base
  • Case Portal
  • Community Support
  • Product Life Cycle
  • Support Information
  • About the Community
  • Terms & Conditions
  • Privacy Statement
  • Acceptable Use Policy
  • Employee Login
© 2022 RSA Security LLC or its affiliates. All rights reserved.