LoFP LoFP / some legitimate applications or administrative scripts may use these services for ip validation or geolocation. filter as needed for approved administrative tools.

Techniques

Sample rules

Windows PowerShell Invoke-RestMethod IP Information Collection

Description

The following analytic detects the use of PowerShell’s Invoke-RestMethod cmdlet to collect geolocation data from ipinfo.io or IP address information from api.ipify.org. This behavior leverages PowerShell Script Block Logging to identify scripts that gather external IP information and potential geolocation data. This activity is significant as it may indicate reconnaissance efforts, where threat actors are attempting to determine the geographical location or network details of a compromised system. While some legitimate software may use these services, this pattern is commonly observed in malware and post-exploitation toolkits like those used by Water Gamayun threat actors.

Detection logic

`powershell` EventCode=4104 (ScriptBlockText="*Invoke-RestMethod*" AND (ScriptBlockText="*ipinfo.io*" OR ScriptBlockText="*api.ipify.org*")) 
| stats count min(_time) as firstTime max(_time) as lastTime by dest signature signature_id user_id vendor_product Guid Opcode Name Path ProcessID ScriptBlockId ScriptBlockText 
| `security_content_ctime(firstTime)` 
| `security_content_ctime(lastTime)` 
| `windows_powershell_invoke_restmethod_ip_information_collection_filter`