124
Threat Hunting with Splunk Presenter: Ken Westin M.Sc, OSCP, ITPM Splunk, Security Market Specialist

Threat Hunting with Splunk

  • Upload
    splunk

  • View
    576

  • Download
    8

Embed Size (px)

Citation preview

Page 1: Threat Hunting with Splunk

ThreatHuntingwithSplunkPresenter:KenWestinM.Sc,OSCP,ITPMSplunk,SecurityMarketSpecialist

Page 2: Threat Hunting with Splunk

Prework fortoday

● SetupSplunk EnterpriseSecuritySandbox● InstallfreeSplunk onlaptop● InstallMLToolkitapp

https://splunkbase.splunk.com/app/2890/

Page 3: Threat Hunting with Splunk

3

> [email protected] @kwestin

• 1yearatSplunk– SecuritySpecialist• BasedinPortland,Oregon• 17yearsintechnologyandsecurity• M.Sc,OSCP,ITPM• Trainedinoffensive&defensivesecurity• Putbadguysinjail…withdata

$whoami

Page 4: Threat Hunting with Splunk

Agenda• ThreatHuntingBasics

• ThreatHuntingDataSources

• Sysmon EndpointData

• CyberKillChain

• WalkthroughofAttackScenarioUsingCoreSplunk (handson)

• AdvancedThreatHuntingTechniques(DependingonTime)

• EnterpriseSecurityWalkthrough

• ApplyingMachineLearningandDataSciencetoSecurity

Page 5: Threat Hunting with Splunk

LogInCredentials

January,February&March https://od-threathunting-01.splunkoxygen.comApril,May&June https://od-threathunting-02.splunkoxygen.comJuly and August https://od-threathunting-03.splunkoxygen.comSeptemberandOctober https://od-threathunting-04.splunkoxygen.comNovemberandDecember https://od-threathunting-05.splunkoxygen.com

User:hunterPass:pr3dator

BirthMonth

Page 6: Threat Hunting with Splunk

Thesewon’twork…

Page 7: Threat Hunting with Splunk

AmIintherightplace?

Somefamiliaritywith…

● CSIRT/SOCOperations

● GeneralunderstandingofThreatIntelligence

● GeneralunderstandingofDNS,Proxy,andEndpointtypesofdata

7

Page 8: Threat Hunting with Splunk

Thisisahands-onsession.

Theoverviewslidesareimportantforbuildingyour“hunt”methodology

10minutes- Seriously.

Page 9: Threat Hunting with Splunk

Whatisthreathunting,whydoyouneedit?TheWhat?

• Threathunting- theactofaggressively

intercepting,trackingand

eliminatingcyberadversariesasearlyaspossible intheCyberKillChain 2

9

TheWhy?

• Threatsarehuman.Focusedandfundedadversarieswillnotbecounteredbysecurityboxesonthenetwork

alone.Threathuntersareactivelysearchingforthreatstopreventor

minimizedamage[beforeithappens] 1

2 CyberThreatHunting- SamuelAlonsoblog,Jan20161 TheWho,What,Where,When,WhyandHowof EffectiveThreatHunting,SANSFeb2016

“ThreatHuntingisnotnew,it’sjustevolving!”

Page 10: Threat Hunting with Splunk
Page 11: Threat Hunting with Splunk

ThreatHuntingwithSplunk

11

Vs.

Page 12: Threat Hunting with Splunk

Search&Visualisation

Enrichment

Data

Automation

12

HumanThreatHunter

KeyBuildingBlockstoDriveThreatHuntingMaturity

Ref:TheheWho,What,Where,When,WhyandHowof EffectiveThreatHunting,SANSFeb2016

Objectives> Hypotheses> Expertise

Page 13: Threat Hunting with Splunk

“Agoodintelligenceofficercultivatesanawarenessofwhatheorshedoesnotknow.Youneedadoseofmodestytoacknowledgeyourownignorance- evenmore,toseekoutyourignorance.Thentheharderpartcomes,tryingtodosomethingaboutit.Thisoftenrequiresanimmodestdetermination”HenryA.CrumptonTheArtofIntelligence:LessonsFromAlifeIntheCIA’sClandestineService

13

Page 14: Threat Hunting with Splunk

SANSThreatHuntingMaturity

14

AdHocSearch

StatisticalAnalysis

VisualizationTechniques

Aggregation MachineLearning/DataScience

85%55%50%48%32%

Source:SANSIR&ThreatHuntingSummit2016

Page 15: Threat Hunting with Splunk

Search&Visualisation

Enrichment

Data

Automation

HumanThreatHunter

HowSplunkhelpsYouDriveThreatHuntingMaturity

ThreatHuntingAutomationIntegrated&outoftheboxautomationtoolingfromartifactquery,contextual“swim-laneanalysis”,anomaly&timeseriesanalysistoadvanceddatascienceleveragingmachinelearning

ThreatHuntingDataEnrichmentEnrichdatawithcontextandthreat-intelacrossthestackortime

todiscerndeeperpatternsorrelationships

Search&VisualiseRelationshipsforFasterHuntingSearchandcorrelatedatawhilevisuallyfusingresultsforfaster

context,analysisandinsight

Ingest&OnboardAnyThreatHuntingMachineDataSourceEnablefastingestionofanymachinedatathroughefficient

indexing,abigdatarealtimearchitectureand‘schemaontheread’technology

Hypotheses

AutomatedAnalytics

DataScience&MachineLearning

Data&IntelligenceEnrichment

DataSearch

Visualisation

Maturity

Page 16: Threat Hunting with Splunk

HuntingTools:InternalData

16

• IPAddresses:threatintelligence,blacklist,whitelist,reputationmonitoringTools:Firewalls,proxies,Splunk Stream,Bro,IDS

• NetworkArtifactsandPatterns:networkflow,packetcapture,activenetworkconnections,historicnetworkconnections,portsandservicesTools:Splunk Stream,BroIDS,FPC,Netflow

• DNS:activity,queriesandresponses,zonetransferactivityTools:Splunk Stream,BroIDS,OpenDNS

• Endpoint– HostArtifactsandPatterns:users,processes,services,drivers,files,registry,hardware,memory,diskactivity,filemonitoring:hashvalues,integritycheckingandalerts,creationordeletionTools:Windows/Linux,CarbonBlack,Tanium,Tripwire,ActiveDirectory

• VulnerabilityManagementDataTools:TripwireIP360,Qualys,Nessus

• UserBehaviorAnalytics:TTPs,usermonitoring,timeofdaylocation,HRwatchlistSplunk UBA,(Alloftheabove)

Page 17: Threat Hunting with Splunk

Persist,Repeat

ThreatIntelligence

Access/Identity

Endpoint

Network

Attacker,knowrelay/C2sites,infectedsites,IOC,attack/campaignintentandattribution

Wheretheywentto,whotalkedtowhom,attacktransmitted,abnormaltraffic,malwaredownload

Whatprocessisrunning(malicious,abnormal,etc.)Processowner,registrymods,attack/malwareartifacts,patchinglevel,attacksusceptibility

Accesslevel,privilegedusers,likelihoodofinfection,wheretheymightbeinkillchain

• Third-partythreatintel• Open-sourceblacklist• Internalthreatintelligence

• Firewall,IDS,IPS• DNS• Email

• Endpoint(AV/IPS/FW)• Malwaredetection• PCLM

• DHCP• OSlogs• Patching

• ActiveDirectory• LDAP• CMDB

• Operatingsystem• Database• VPN,AAA,SSO

TypicalDataSources

• Webproxy• NetFlow• Network

Page 18: Threat Hunting with Splunk

Endpoint:MicrosoftSysmonPrimer

18

● TAAvailableontheAppStore

● GreatBlogPosttogetyoustarted

● IncreasesthefidelityofMicrosoftLogging

BlogPost:http://blogs.splunk.com/2014/11/24/monitoring-network-traffic-with-sysmon-and-splunk/

Page 19: Threat Hunting with Splunk

User:hunterPass:pr3dator

January,February&March https://od-threathunting-01.splunkoxygen.comApril,May&June https://od-threathunting-02.splunkoxygen.comJuly and August https://od-threathunting-03.splunkoxygen.comSeptemberandOctober https://od-threathunting-04.splunkoxygen.comNovemberandDecember https://od-threathunting-05.splunkoxygen.com

Page 20: Threat Hunting with Splunk

SysmonEventTags

20

MapsNetworkCommtoprocess_id

Process_idcreationandmappingtoparentprocess_id

Page 21: Threat Hunting with Splunk

sourcetype=X*|searchtag=communicate

21

Page 22: Threat Hunting with Splunk

sourcetype=X*|deduptag|searchtag=process

22

Page 23: Threat Hunting with Splunk

DataSourceMapping

Page 24: Threat Hunting with Splunk

DemoStory- KillChainFrameworkSuccessfulbruteforce– downloadsensitivepdfdocument

WeaponizethepdffilewithZeusMalware

Convincingemailsentwithweaponizedpdf

Vulnerablepdfreaderexploitedbymalware.Droppercreatedonmachine

Dropperretrievesandinstallsthemalware

Persistenceviaregularoutboundcomm

DataExfiltration

Source:LockheedMartin

Page 25: Threat Hunting with Splunk

Servers

Storage

DesktopsEmail Web

TransactionRecords

NetworkFlows

DHCP/DNS

HypervisorCustomApps

PhysicalAccess

Badges

ThreatIntelligence

Mobile

CMDB

IntrusionDetection

Firewall

DataLossPrevention

Anti-Malware

VulnerabilityScans

Traditional

Authentication

StreamInvestigations– chooseyourdatawisely

25

Page 26: Threat Hunting with Splunk

26

Let’sdigin!

Please,raisethathandifyouneedustohitthepausebutton

Page 27: Threat Hunting with Splunk

APTTransactionFlowAcrossDataSources

27

http(proxy)sessiontocommand&controlserver

RemotecontrolStealdataPersistincompanyRentasbotnet

Proxy

ConductBusiness

Createadditionalenvironment

GainAccesstosystemTransaction

ThreatIntelligence

Endpoint

NetworkEmail,Proxy,DNS,andWeb

DataSources

.pdf

.pdf executes&unpacksmalwareoverwritingandrunning“allowed”programs

Svchost.exe(malware)

Calc.exe(dropper)

AttackerhackswebsiteSteals.pdf files

WebPortal

.pdf

Attackercreatesmalware,embed in.pdf,

emailstothetarget

MAIL

Reademail,openattachment

OurInvestigationbeginsbydetectinghighriskcommunicationsthroughtheproxy,attheendpoint,andevenaDNScall.

Page 28: Threat Hunting with Splunk

index=zeus_demo3

28

insearch:

Page 29: Threat Hunting with Splunk

Tobeginourinvestigation,wewillstartwithaquicksearchtofamiliarizeourselveswiththedatasources.

Inthisdemoenvironment,wehaveavarietyofsecurityrelevantdataincluding…

WebDNSProxyFirewallEndpointEmail

Page 30: Threat Hunting with Splunk

Takealookattheendpointdatasource.WeareusingtheMicrosoftSysmon TA.

Wehaveendpointvisibilityintoallnetworkcommunicationandcanmapeachconnectionbacktoaprocess.

}Wealsohavedetailedinfooneachprocessandcanmapitbacktotheuserandparentprocess.}

Letsgetourdaystartedbylookingusingthreatintel toprioritizeoureffortsandfocusoncommunicationwithknown highriskentities.

Page 31: Threat Hunting with Splunk

WehavemultiplesourceIPscommunicatingtohighriskentitiesidentifiedbythese2threatsources.

Weareseeinghighriskcommunicationfrommultipledatasources.

Weseemultiplethreatintel relatedeventsacrossmultiplesourcetypesassociatedwiththeIPAddressofChrisGilbert.Let’stakecloserlookattheIPAddress.

Wecannowseetheownerofthesystem(ChrisGilbert)andthatitisn’taPIIorPCIrelatedasset,sotherearenoimmediatebusinessimplicationsthatwouldrequireinformingagenciesorexternalcustomerswithinacertaintimeframe.

Thisdashboardisbasedoneventdatathatcontainsathreatintelbasedindicatormatch(IPAddress,domain,etc.).ThedataisfurtherenrichedwithCMDBbasedAsset/identityinformation.

Page 32: Threat Hunting with Splunk

Wearenowlookingatonlythreatintel relatedactivityfortheIPAddressassociatedwithChrisGilbertandseeactivityspanningendpoint,proxy,andDNSdatasources.

Thesetrendlinestellaveryinterestingvisualstory.ItappearsthattheassetmakesaDNSqueryinvolvingathreatintel relateddomainorIPAddress.

ScrollDo

wn

Scrolldownthedashboardtoexaminethesethreatintel eventsassociatedwiththeIPAddress.

Wethenseethreatintel relatedendpointandproxyeventsoccurringperiodicallyandlikelycommunicatingwithaknownZeusbotnetbasedonthethreatintelsource(zeus_c2s).

Page 33: Threat Hunting with Splunk

It’sworthmentioningthatatthispointyoucouldcreateatickettohavesomeonere-imagethemachinetopreventfurtherdamageaswecontinueourinvestigationwithinSplunk.

Withinthesamedashboard,wehaveaccesstoveryhighfidelityendpointdatathatallowsananalysttocontinuetheinvestigationinaveryefficientmanner.Itisimportanttonotethatnearreal-timeaccesstothistypeofendpointdataisnotnotcommonwithinthetraditionalSOC.

Theinitialgoaloftheinvestigationistodeterminewhetherthiscommunicationismaliciousorapotentialfalsepositive.Expandtheendpointeventtocontinuetheinvestigation.

Proxyrelatedthreatintel matchesareimportantforhelpingustoprioritizeoureffortstowardinitiatinganinvestigation.Furtherinvestigationintotheendpointisoftenverytimeconsumingandofteninvolvesmultipleinternalhand-offstootherteamsorneedingtoaccessadditionalsystems.Thisencryptedproxytrafficisconcerningbecauseofthelargeamountofdata(~1.5MB)beingtransferredwhichiscommonwhendataisbeingexfiltrated.

Page 34: Threat Hunting with Splunk

Exfiltrationofdataisaseriousconcernandoutboundcommunicationtoexternalentitythathasaknownthreatintelindicator,especiallywhenitisencryptedasinthiscase.

Letscontinuetheinvestigation.

Anotherclue.Wealsoseethatsvchost.exe shouldbelocatedinaWindowssystemdirectorybutthisisbeingrunintheuserspace.Notgood.

Weimmediatelyseetheoutboundcommunicationwith115.29.46.99viahttpsisassociatedwiththesvchost.exeprocessonthewindowsendpoint.Theprocessidis4768.ThereisagreatdealmoreinformationfromtheendpointasyouscrolldownsuchastheuserIDthatstartedtheprocessandtheassociatedCMDBenrichmentinformation.

Page 35: Threat Hunting with Splunk

WehaveaworkflowactionthatwilllinkustoaProcessExplorerdashboardandpopulateitwiththeprocessidextractedfromtheevent(4768).

Page 36: Threat Hunting with Splunk

ThisisastandardWindowsapp,butnotinitsusualdirectory,tellingusthatthemalwarehasagainspoofedacommonfilename.

Wealsocanseethattheparentprocessthatcreatedthissuspicuous svchost.exe processiscalledcalc.exe.

ThishasbroughtustotheProcessExplorerdashboardwhichletsusviewWindowsSysmon endpointdata.

SuspectedMalware

Letscontinuetheinvestigationbyexaminingtheparentprocessasthisisalmostcertainlyagenuinethreatandwearenowworkingtowardarootcause.

ThisisveryconsistentwithZeusbehavior.TheinitialexploitationgenerallycreatesadownloaderordropperthatwillthendownloadtheZeusmalware.Itseemslikecalc.exemaybethatdownloader/dropper.

SuspectedDownloader/Dropper

Thisprocesscallsitself“svchost.exe,”acommonWindowsprocess,butthepathisnotthenormalpathforsvchost.exe.

…whichisacommontraitofmalwareattemptingtoevadedetection.WealsoseeitmakingaDNSquery(port53)thencommunicatingviaport443.

Page 37: Threat Hunting with Splunk

TheParentProcessofoursuspecteddownloader/dropperisthelegitimatePDFReaderprogram.Thiswilllikelyturnouttobethevulnerableappthatwasexploitedinthisattack.

SuspectedDownloader/Dropper

SuspectedVulnerableAppWehaveveryquicklymovedfromthreatintel relatednetworkandendpointactivitytothelikelyexploitationofavulnerableapp.Clickontheparentprocesstokeepinvestigating.

Page 38: Threat Hunting with Splunk

WecanseethatthePDFReaderprocesshasnoidentifiedparentandistherootoftheinfection.

ScrollDo

wn

ScrolldownthedashboardtoexamineactivityrelatedtothePDFreaderprocess.

Page 39: Threat Hunting with Splunk

Chrisopened2nd_qtr_2014_report.pdfwhichwasanattachmenttoanemail!

Wehaveourrootcause!Chrisopenedaweaponized .pdf filewhichcontainedtheZeusmalware.Itappearstohavebeendeliveredviaemailandwehaveaccesstoouremaillogsasoneofourimportantdatasources.Letscopythefilename2nd_qtr_2014_report.pdfandsearchabitfurthertodeterminethescopeofthiscompromise.

Page 40: Threat Hunting with Splunk

Letsdigalittlefurtherinto2nd_qtr_2014_report.pdftodeterminethescopeofthiscompromise.

Page 41: Threat Hunting with Splunk

index=zeus_demo32nd_qtr_2014_report.pdf

41

insearch:

Page 42: Threat Hunting with Splunk

Letssearchthoughmultipledatasourcestoquicklygetasenseforwhoelsemayhavehavebeenexposedtothisfile.

Wewillcomebacktothewebactivitythatcontainsreferencetothepdf filebutletsfirstlookattheemaileventtodeterminethescopeofthisapparentphishingattack.

Page 43: Threat Hunting with Splunk

Wehaveaccesstotheemailbodyandcanseewhythiswassuchaconvincingattack.Thesenderapparentlyhadaccesstosensitiveinsiderknowledgeandhintedatquarterlyresults.

Thereisourattachment.

HoldOn!That’snotourDomainName!Thespellingisclosebutit’smissinga“t”.TheattackerlikelyregisteredadomainnamethatisveryclosetothecompanydomainhopingChriswouldnotnotice.

Thislookstobeaverytargetedspearphishingattackasitwassenttoonlyoneemployee(Chris).

Page 44: Threat Hunting with Splunk

RootCauseRecap

44

DataSources

.pdf executes&unpacksmalwareoverwritingandrunning“allowed”programs

http(proxy)sessiontocommand&controlserver

RemotecontrolStealdataPersistincompanyRentasbotnet

Proxy

ConductBusiness

Createadditionalenvironment

GainAccesstosystemTransaction

ThreatIntelligence

Endpoint

NetworkEmail,Proxy,DNS,andWeb

.pdfSvchost.exe(malware)

Calc.exe(dropper)

AttackerhackswebsiteSteals.pdf files

WebPortal

.pdf

Attackercreatesmalware,embed in.pdf,

emailstothetarget

MAIL

Reademail,openattachment

Weutilizedthreatintel todetectcommunicationwithknownhighriskindicatorsandkickoffourinvestigationthenworkedbackwardthroughthekillchaintowardarootcause.

Keytothisinvestigativeprocessistheabilitytoassociatenetworkcommunicationswithendpointprocessdata.

ThishighvalueandveryrelevantabilitytoworkamalwarerelatedinvestigationthroughtorootcausetranslatesintoaverystreamlinedinvestigativeprocesscomparedtothelegacySIEMbasedapproach.

Page 45: Threat Hunting with Splunk

45

Letsrevisitthesearchforadditionalinformationonthe2nd_qtr_2014-_report.pdffile.

Weunderstandthatthefilewasdeliveredviaemailandopenedattheendpoint.Whydoweseeareferencetothefileintheaccess_combined (webserver)logs?

Selecttheaccess_combinedsourcetype toinvestigatefurther.

Page 46: Threat Hunting with Splunk

46

Theresultsshow54.211.114.134hasaccessedthisfilefromthewebportalofbuttergames.com.

ThereisalsoaknownthreatintelassociationwiththesourceIPAddressdownloading(HTTPGET)thefile.

Page 47: Threat Hunting with Splunk

47

SelecttheIPAddress,left-click,thenselect“Newsearch”.WewouldliketounderstandwhatelsethisIPAddresshasaccessedintheenvironment.

Page 48: Threat Hunting with Splunk

48

That’sanabnormallylargenumberofrequestssourcedfromasingleIPAddressina~90minutewindow.

Thislookslikeascriptedactiongiventheconstanthighrateofrequestsoverthebelowwindow.

ScrollDo

wn

Scrolldownthedashboardtoexamineotherinterestingfieldstofurtherinvestigate.

NoticetheGooglebotuseragent string whichisanotherattempttoavoidraisingattention..

Page 49: Threat Hunting with Splunk

49

Therequestsfrom52.211.114.134aredominatedbyrequeststotheloginpage(wp-login.php).It’sclearlynotpossibletoattemptaloginthismanytimesinashortperiodoftime– thisisclearlyascriptedbruteforceattack.

Aftersuccessfullygainingaccesstoourwebsite,theattackerdownloadedthepdf file,weaponized itwiththezeusmalware,thendeliveredittoChrisGilbertasaphishingemail.

Theattackerisalsoaccessingadminpageswhichmaybeanattempttoestablishpersistenceviaabackdoorintothewebsite.

Page 50: Threat Hunting with Splunk

KillChainAnalysisAcrossDataSources

50

http(proxy)sessiontocommand&controlserver

RemotecontrolStealdataPersistincompanyRentasbotnet

Proxy

ConductBusiness

Createadditionalenvironment

GainAccesstosystemTransaction

ThreatIntelligence

Endpoint

NetworkEmail,Proxy,DNS,andWeb

DataSources

.pdf

.pdf executes&unpacksmalwareoverwritingandrunning“allowed”programs

Svchost.exe(malware)

Calc.exe(dropper)

AttackerhackswebsiteSteals.pdf files

WebPortal

.pdf

Attackercreatesmalware,embed in.pdf,

emailstothetarget

MAIL

Reademail,openattachment

Wecontinuedtheinvestigationbypivotingintotheendpointdatasourceandusedaworkflowactiontodeterminewhichprocessontheendpointwasresponsiblefortheoutboundcommunication.

WeBeganbyreviewingthreatintel relatedeventsforaparticularIPaddressandobservedDNS,Proxy,andEndpointeventsforauserinSales.

Investigationcomplete!LetsgetthisturnedovertoIncidentReponse team.

Wetracedthesvchost.exeZeusmalwarebacktoit’sparentprocessIDwhichwasthecalc.exedownloader/dropper.

Onceourrootcauseanalysiswascomplete,weshiftedoutfocusintotheweblogstodeterminethatthesensitivepdffilewasobtainedviaabruteforceattackagainstthecompanywebsite.

Wewereabletoseewhichfilewasopenedbythevulnerableappanddeterminedthatthemaliciousfilewasdeliveredtotheuserviaemail.

Aquicksearchintothemaillogsrevealedthedetailsbehindthephishingattackandrevealedthatthescopeofthecompromisewaslimitedtojusttheoneuser.

Wetracedcalc.exe backtothevulnerableapplicationPDFReader.

Page 51: Threat Hunting with Splunk

10minBreak!

Page 52: Threat Hunting with Splunk

Appendix- SQLi- LateralMovement-DNSExfilatration

Page 53: Threat Hunting with Splunk

SQLi

Page 54: Threat Hunting with Splunk

SQLInjection● SQLinjection● Codeinjection● OScommanding● LDAPinjection● XMLinjection● XPathinjection● SSIinjection● IMAP/SMTPinjection● Bufferoverflow

Page 55: Threat Hunting with Splunk

ImpervaWebAttacksReport,2015

Page 56: Threat Hunting with Splunk
Page 57: Threat Hunting with Splunk

TheanatomyofaSQLinjectionattack

SELECT * FROM users WHERE email='[email protected]' OR 1 = 1 -- ' AND password='xxx';

[email protected]' OR 1 = 1 -- '

xxx

[email protected]

1234

Anattackermightsupply:

Page 58: Threat Hunting with Splunk

…andsofarthisyear…39

Page 59: Threat Hunting with Splunk

index=web_vuln passwordselect

Page 60: Threat Hunting with Splunk

Whathavewehere?Ourlearningenvironmentconsistsof:

• Abunchofpublically-accessiblesingleSplunk servers

• Eachwith~5.5Mevents,fromrealenvironmentsbutmassaged:

• WindowsSecurityevents• Apachewebaccesslogs• BroDNS&HTTP• PaloAltotrafficlogs• Someothervariousbits

Page 61: Threat Hunting with Splunk

https://splunkbase.splunk.com/app/1528/

SearchforpossibleSQLinjectioninyourevents:ü looksforpatternsinURIqueryfieldtoseeif

anyonehasinjectedthemwithSQLstatements

ü usestandarddeviationsthatare2.5timesgreaterthantheaveragelengthofyourURIqueryfield

Macrosused• sqlinjection_pattern(sourcetype,uri queryfield)• sqlinjection_stats(sourcetype,uri queryfield)

Page 62: Threat Hunting with Splunk

RegularExpressionFTWsqlinjection_rex isasearchmacro.Itcontains:

(?<injection>(?i)select.*?from|union.*?select|\'$|delete.*?from|update.*?set|alter.*?table|([\%27|\'](%20)*=(%20)*[\%27|\'])|\w*[%27|\']or)

Whichmeans:Inthestringwearegiven,lookforANY ofthefollowingmatchesandputthatintothe“injection”field.

• AnythingcontainingSELECTfollowedbyFROM• AnythingcontainingUNIONfollowedbySELECT• Anythingwitha‘attheend• AnythingcontainingDELETEfollowedbyFROM• AnythingcontainingUPDATEfollowedbySET• AnythingcontainingALTERfollowedbyTABLE• A%27ORa‘andthena%20andanyamountofcharactersthena%20andthena%27ORa‘

• Note:%27isencoded“’”and%20isencoded<space>• Anyamountofwordcharactersfollowedbya%27ORa‘andthen“or”

Page 63: Threat Hunting with Splunk

Bonus:TryouttheSQLInjectionapp!

Page 64: Threat Hunting with Splunk

Summary:Webattacks/SQLinjection● SQLinjectionprovideattackerswitheasyaccesstodata

● DetectingadvancedSQLinjectionishard– useanapp!

● UnderstandwhereSQLi ishappeningonyournetworkandputastoptoit.

● AugmentyourWAFwithenterprise-wideSplunk searches.

Page 65: Threat Hunting with Splunk

LateralMovement

Page 66: Threat Hunting with Splunk

Pokingaround

Anattackerhacksanon-privilegedusersystem.

Sowhat?

Page 67: Threat Hunting with Splunk

LateralMovement

LateralMovementistheexpansionofsystemscontrolled,anddataaccessed.

Page 68: Threat Hunting with Splunk

MostfamousLateralMovementattack?(excludingpasswordre-use)

PasstheHash!

Page 69: Threat Hunting with Splunk

DetectingLegacyPtHLookforWindowsEvents:

● EventID:4624or4625

● Logontype:3

● Auth package:NTLM

● Useraccountisnotadomainlogon,orAnonymousLogon

Page 70: Threat Hunting with Splunk

LMDetection:PasstheHash

source=WinEventLog:SecurityEventCode=4624Authentication_Package=NTLMType=Information

Page 71: Threat Hunting with Splunk
Page 72: Threat Hunting with Splunk

Thenitgotharder• PasstheHashtoolshaveimproved• Trackingofjitter,othermetrics• Solet’sdetectlateralmovementdifferently

Page 73: Threat Hunting with Splunk

Networktrafficprovidessourceoftruth● Iusuallytalkto10hosts● ThenonedayItalkto10,000hosts● ALARM!

Page 74: Threat Hunting with Splunk

LMDetection:NetworkDestinations

sourcetype="pan:traffic"|statscountdc(dest)sparkline(dc(dest))bysrc_ip

Page 75: Threat Hunting with Splunk

Consistentlylarge

Inconsistent!

Page 76: Threat Hunting with Splunk

LMDetection:NetworkDestinations

sourcetype="pan:traffic"|bucket_timespan=1d|statscountdc(dest)asNumDests bysrc_ip _time|statsavg(NumDests)asavg stdev(NumDests)asstdev latest(NumDests)aslatestbysrc_ip|wherelatest>2*stdev +avg

Finddailyaverage,standarddeviation,andmostrecent

Page 77: Threat Hunting with Splunk
Page 78: Threat Hunting with Splunk

Splunk UBA

Page 79: Threat Hunting with Splunk

Summary:LateralMovement● Attackersuccessdefinesscopeofabreach● Highdifficulty,highimportance● WorthdoinginSplunk● EasywithUBA

Page 80: Threat Hunting with Splunk

DNSExfiltration

Page 81: Threat Hunting with Splunk

domain=corp;user=dave;password=12345

encrypt

DNSQuery:ZG9tYWluPWNvcnA7dXNlcj1kYXZlO3Bhc3N3b3JkPTEyMzQ1DQoNCg==.attack.com

ZG9tYWluPWNvcnA7dXNlcj1kYXZlO3Bhc3N3b3JkPTEyMzQ1DQoNCg==

Page 82: Threat Hunting with Splunk

DNSexfil tendstobeoverlookedwithinanoceanofDNSdata.

Let’sfixthat!

DNSexfiltration

Page 83: Threat Hunting with Splunk

FrameworkPOS:acard-stealingprogramthatexfiltrates datafromthetarget’snetworkbytransmittingitasdomainnamesystem(DNS)traffic

Butthebigdifferenceisthewayhowstolendataisexfiltrated:themalwareusedDNSrequests!https://blog.gdatasoftware.com/2014/10/23942-new-frameworkpos-

variant-exfiltrates-data-via-dns-requests

“”

…feworganizationsactuallykeepdetailedlogsorrecordsof theDNStraffictraversingtheirnetworks— makingitanidealwaytosiphondatafromahackednetwork.

http://krebsonsecurity.com/2015/05/deconstructing-the-2014-sally-beauty-breach/#more-30872

“”

DNSexfiltration

Page 84: Threat Hunting with Splunk

https://splunkbase.splunk.com/app/2734/

DNSexfil detection– tricksofthetradeü parseURLs&complicatedTLDs(TopLevelDomain)ü calculateShannonEntropy

Listofprovidedlookups• ut_parse_simple(url)• ut_parse(url,list)orut_parse_extended(url,list)• ut_shannon(word)• ut_countset(word,set)• ut_suites(word,sets)• ut_meaning(word)• ut_bayesian(word)• ut_levenshtein(word1,word2)

Page 85: Threat Hunting with Splunk

Examples• Thedomainaaaaa.com hasaShannonEntropyscoreof1.8 (verylow)• Thedomaingoogle.com hasaShannonEntropyscoreof2.6 (ratherlow)• A00wlkj—(-a.aslkn-C.a.2.sk.esasdfasf1111)-890209uC.4.com hasaShannon

Entropyscoreof3 (ratherhigh)

Layman’sdefinition:ascorereflectingtherandomness ormeasureofuncertainty ofastring

ShannonEntropy

Page 86: Threat Hunting with Splunk

DetectingDataExfiltration

index=brosourcetype=bro_dns|`ut_parse(query)`|`ut_shannon(ut_subdomain)`|eval sublen =length(ut_subdomain)|tableut_domain ut_subdomainut_shannon sublen

TIPSq LeverageourBroDNSdataq CalculateShannonEntropyscoresq Calculatesubdomainlengthq DisplayDetails

Page 87: Threat Hunting with Splunk

Let’sgethandson!

DNSExfiltration

Page 88: Threat Hunting with Splunk

DetectingDataExfiltration

…|statscountavg(ut_shannon)asavg_shaavg(sublen)asavg_sublenstdev(sublen)asstdev_sublenbyut_domain|searchavg_sha>3avg_sublen>20stdev_sublen<2

TIPSq LeverageourBroDNSdataq CalculateShannonEntropyscoresq Calculatesubdomainlengthq Displaycount,scores,lengths,

deviations

Page 89: Threat Hunting with Splunk

DetectingDataExfiltrationRESULTS• Exfiltrating datarequiresmanyDNSrequests– lookforhighcounts• DNSexfiltrationtomooo.com and chickenkiller.com

Page 90: Threat Hunting with Splunk

Summary:DNSexfiltration● ExfiltrationbyDNSandICMPisaverycommontechnique● ManyorganizationsdonotanalyzeDNSactivity– donotbelikethem!● NoDNSlogs?NoSplunkStream?LookatFWbytecounts

Page 91: Threat Hunting with Splunk

http://www.slideshare.net/kwestin/workshop-threathunting

Page 92: Threat Hunting with Splunk

Splunk EnterpriseSecurity

Page 93: Threat Hunting with Splunk

93

SplunkEnterprise

- BigDataAnalyticsPlatform-

SplunkEnterpriseSecurity

- SecurityAnalyticsPlatform-

ThreatHuntingwithSplunk

Hypotheses

AutomatedAnalytics

DataScience&MachineLearning

Data&IntelligenceEnrichment

DataSearch

Visualisation

Maturity

ThreatHuntingDataEnrichment

ThreatHuntingAutomation

Ingest&OnboardAnyThreatHunting

MachineDataSource

Search&VisualiseRelationshipsforFasterHunting

Page 94: Threat Hunting with Splunk

OtherItemsToNote

ItemstoNote

Navigation- HowtoGetHere

Descriptionofwhattoclickon

Click

Page 95: Threat Hunting with Splunk

KeySecurityIndicators(buildyourown!)

Sparklines

Editable

Page 96: Threat Hunting with Splunk

Variouswaystofilterdata

Malware-SpecificKSIsandReports

SecurityDomains->Endpoint->MalwareCenter

Page 97: Threat Hunting with Splunk

Filterable

KSIsspecifictoRisk

Riskassignedtosystem,userorother

UnderAdvancedThreat,selectRiskAnalysis

Page 98: Threat Hunting with Splunk

(ScrollDown)

RecentRiskActivity

UnderAdvancedThreat,selectRiskAnalysis

Page 99: Threat Hunting with Splunk

Filterable,downtoIoC

KSIsspecifictoThreat

Mostactivethreatsource

Scrolldown… Scroll

UnderAdvancedThreat,selectThreatActivity

Page 100: Threat Hunting with Splunk

Specificsaboutrecentthreatmatches

UnderAdvancedThreat,selectThreatActivity

Page 101: Threat Hunting with Splunk

Toaddthreatintelgoto:Configure->DataEnrichment->ThreatIntelligenceDownloads

Click

Page 102: Threat Hunting with Splunk

Click“ThreatArtifacts”Under“AdvancedThreat”

Click

Page 103: Threat Hunting with Splunk

ArtifactCategories–clickdifferenttabs…

STIXfeed

Customfeed

UnderAdvancedThreat,selectThreatArtifacts

Page 104: Threat Hunting with Splunk

ReviewtheAdvancedThreatcontent

Click

Page 105: Threat Hunting with Splunk

DatafromassetframeworkConfigurableSwimlanes

Darker=moreevents

AllhappenedaroundsametimeChangeto“Today”ifneeded

AssetInvestigator,enter“192.168.56.102”

Page 106: Threat Hunting with Splunk

DataScience&MachineLearningInSecurity

106

Page 107: Threat Hunting with Splunk

Disclaimer:Iamnotadatascientist

Page 108: Threat Hunting with Splunk

TypesofMachineLearningSupervised Learning:generalizingfromlabeled data

Page 109: Threat Hunting with Splunk

SupervisedMachineLearning

109

DomainName TotalCnt RiskFactor AGD SessionTime RefEntropy NullUa Outcome

yyfaimjmocdu.com 144 6.05 1 1 0 0 Maliciousjjeyd2u37an30.com 6192 5.05 0 1 0 0 Maliciouscdn4s.steelhousemedia.com 107 3 0 0 0 0 Benignlog.tagcade.com 111 2 0 1 0 0 Benigngo.vidprocess.com 170 2 0 0 0 0 Benignstatse.webtrendslive.com 310 2 0 1 0 0 Benigncdn4s.steelhousemedia.com 107 1 0 0 0 0 Benignlog.tagcade.com 111 1 0 1 0 0 Benign

Page 110: Threat Hunting with Splunk

Unsupervised Learning:generalizingfromunlabeled data

Page 111: Threat Hunting with Splunk

UnsupervisedMachineLearning

• Notuning

• Programmaticallyfindstrends

• UBAisprimarilyunsupervised

• Rigorouslytestedforfit

111

AlgorithmRawSecurityData AutomatedClustering

Page 112: Threat Hunting with Splunk

112

Page 113: Threat Hunting with Splunk

MLToolkit&Showcase• SplunkSupportedframeworkforbuildingMLApps

– Getitforfree:http://tiny.cc/splunkmlapp

• LeveragesPythonforScientificComputing (PSC)add-on:– Open-sourcePythondatascienceecosystem– NumPy,SciPy,scitkit-learn,pandas,statsmodels

• Showcaseusecases:PredictHardDriveFailure,ServerPowerConsumption,ApplicationUsage,CustomerChurn&more

• Standardalgorithms outofthebox:– Supervised:LogisticRegression,SVM,LinearRegression,RandomForest,etc.– Unsupervised: KMeans,DBSCAN,SpectralClustering,PCA,KernelPCA,etc.

• Implementoneof300+algorithmsbyeditingPythonscripts

Page 114: Threat Hunting with Splunk

MachineLearningToolkitDemo

114

Page 115: Threat Hunting with Splunk
Page 116: Threat Hunting with Splunk

Splunk UBA

Page 117: Threat Hunting with Splunk

117

SplunkEnterprise

- BigDataAnalyticsPlatform-

SplunkEnterpriseSecurity

- SecurityAnalyticsPlatform-

ThreatHuntingwithSplunk

ThreatHuntingDataEnrichment

ThreatHuntingAutomation

Ingest&OnboardAnyThreatHunting

MachineDataSource

Search&VisualiseRelationshipsforFasterHunting

Hypotheses

AutomatedAnalytics

DataScience&MachineLearning

Data&IntelligenceEnrichment

DataSearch

Visualisation

Maturity

UserBehaviorAnalytics

- SecurityDataSciencePlatform-

Page 118: Threat Hunting with Splunk

118

MachineLearningSecurityUseCasesMachine

LearningUseCases

PolymorphicAttackAnalysis

BehavioralPeerGroupAnalysis

User&EntityBehaviorBaseline

Entropy/RareEventDetection

CyberAttack/ExternalThreatDetection

Reconnaissance,BotnetandC&CAnalysis

LateralMovementAnalysis

StatisticalAnalysis

DataExfiltrationModels

IPReputationAnalysis

InsiderThreatDetection

User/DeviceDynamicFingerprinting

Page 119: Threat Hunting with Splunk

Splunk UBAUseCases

ACCOUNTTAKEOVER• Privilegedaccountcompromise• Dataexfiltration

LATERALMOVEMENT• Pass-the-hashkillchain• Privilegeescalation

SUSPICIOUSACTIVITY• Misuseofcredentials• Geo-locationanomalies

MALWAREATTACKS• Hiddenmalwareactivity

BOTNET,COMMAND&CONTROL• Malwarebeaconing• Dataleakage

USER&ENTITYBEHAVIORANALYTICS• Suspiciousbehaviorbyaccountsor

devices

EXTERNALTHREATSINSIDERTHREATS

Page 120: Threat Hunting with Splunk

SplunkUserBehaviorAnalytics(UBA)• ~100%ofbreachesinvolvevalidcredentials(Mandiant Report)• Needtounderstandnormal&anomalousbehaviorsforALLusers• UBAdetectsAdvancedCyberattacks andMaliciousInsiderThreats• LotsofMLunderthehood:

– BehaviorBaselining&Modeling– AnomalyDetection(30+models)– AdvancedThreatDetection

• E.g.,DataExfil Threat:– “Sawthisstrangelogin&datatransferfor userkwestin

at3aminChina…”– SurfacethreattoSOCAnalysts

Page 121: Threat Hunting with Splunk

RAW SECURITY EVENTS

ANOMALIES ANOMALY CHAINS

(THREATS)

MACHINELEARNING

GRAPHMINING

THREAT MODELS

Lateral MovementBeaconingLand-Speed Violation

HCI

Anomalies graphEntity relationship graph

Kill chain sequenceForensic artifactsThreat/Risk scoring

FEEDBACK

Page 122: Threat Hunting with Splunk

Splunk UBADemo

122

Page 123: Threat Hunting with Splunk

SecurityWorkshops

● ThreatIntelligenceWorkshop● InsiderThreat● CSC20Workshop● SIEM+● Splunk UBADataScienceWorkshop● EnterpriseSecurityBenchmarkAssessment

Page 124: Threat Hunting with Splunk

SecurityWorkshopSurvey

https://www.surveymonkey.com/r/NL7RN6B

[email protected]:@kwestinlinkedin.com/in/kwestin