When an IP Address Looks Like a Number

Hunting decimal IPv4 obfuscation in ClickFix activity with Microsoft Defender XDR

Most commands look fine at a glance. Then one small detail gives them away.

I was digging into a ClickFix attack when I spotted two curl.exe processes in the process tree, both writing to files in the user's Temp folder. That part didn't bother me much. The destination did, because it wasn't a normal website or an IP address:

1566454813/455

Thre is no domain name, no dots and no http://. If you scrolled past it in a process tree, you would probably take it for an ID or a build number and keep going.

But It’s actually an IP address.

We found it while working a ClickFix case. ClickFix is the trick where a fake CAPTCHA or “fix this error” page talks someone into pasting a command and running it themselves. Two curl.exe processes showed up in the process tree, and both pointed at that odd number. The network log for the same processes showed a successful connection to 93.94.52.29.

The two values look nothing alike, yet they are the same address.

That left us with an uncomfortable question. If our hunts only look for IP addresses written with dots, what else are we walking past?

What we saw

This is the part of the process tree that mattered:

explorer.exe
└── cmd.exe
├── curl.exe → command specified crandle.txt as output
├── curl.exe → command specified Z797.ps1 as output
└── powershell.exe → csc.exe / ilasm.exe → browser processes

Both curl commands referenced files in the user’s temp folder. The second one named Z797.ps1 as its output. A short time later, PowerShell started with a command that mentioned the same script name. Network telemetry showed the curl processes connecting successfully to the decoded IP.

Defender also raised alerts for possible process injection during the wider incident.

What this does and doesn’t prove

It is very easy to look at a tree like that and write the whole story in your head. We tried hard not to.

Nothing here shows persistence either. Each of those bigger claims needs its own evidence, and we come back to that in the triage steps below.

How a number becomes an IP address

An IPv4 address is four numbers, each between 0 and 255. Each of those numbers (called an octet) fits in one byte, so the whole address is four bytes. Four bytes can also be read as one big number: an unsigned 32-bit integer, which Windows people often call a DWORD.

Think of time. “An hour and a half” and “5,400 seconds” are the same amount of time. One is just easier for a person to read.

For our address, the math goes like this:

93.94.52.29

= (93 × 256³) + (94 × 256²) + (52 × 256) + 29
= 1566454813

To go the other way, run print format_ipv4(1566454813) in Advanced Hunting.

Nothing is encrypted here. It is the same address with a different spelling.

Does a tool really accept this? curl does. The curl URL documentation describes support for numerical IPv4 forms, and for URLs with no scheme in front. That is how something as bare as 1566454813/455 can work as a destination. Other programs may read the same text in a different way, so test the tool you are dealing with before you assume anything.

Why a simple search misses it

Say you have a detection that searches command lines for a known bad IP: 93.94.52.29and it will never match this 1566454813.

A regex for “four numbers with dots between them” fails for the same reason. The process log keeps the number as it was typed and the network log keeps the real IP, so a plain text search never connects the two.

None of this means every large number is bad. Command lines are full of numbers: timeouts, ports, sizes, IDs. A number gets interesting when it sits where a destination should be, and more so when the decoded address also shows up in the network log.

The hunting hypothesis

An attacker may use a single-integer IPv4 address in a command to make a destination less obvious. Extracting that number, converting it to dotted form, and comparing it with endpoint telemetry can reveal the behavior without relying on one known IP address.

The investigation becomes a three-step process:

  1. Find a possible decimal IP in a command or autorun entry.
  2. Decode it to a dotted IPv4 address.
  3. Correlate it with network, process, and Registry evidence.

1.Find curl commands with a possible decimal IP

This hunt looks at curl.exe process creation events and keeps the ones where a number sits in the host position, either in an explicit HTTP URL or as a scheme-less number followed by a path. It does not need a successful connection, so it still works when the request failed or the network event is missing.

DeviceProcessEvents
| where Timestamp > ago(14d)
| where ActionType == "ProcessCreated"
| where FileName in~ ("curl.exe", "curl")
| where not(ProcessCommandLine has "example.com" or ProcessCommandLine has "example2.com") //Exclude known automation script domains
| extend Words = split(replace_regex(ProcessCommandLine, @'[\t\r\n]', ' '),' ')
| mv-expand with_itemindex=TokenIndex Token = Words to typeof(string)
| extend Previous = iff(TokenIndex > 0,trim(@'[\x22\x27]', tostring(Words[TokenIndex - 1])),'')
| extend Token = trim(@'[\x22\x27]', Token)
| extend Token = trim( @'[\x22\x27]',replace_regex(Token, @'(?i)^--url=', ''))
| where not(Previous startswith '-') or Previous =~ '--url'
| where Token matches regex @'(?i)^https?://[1-9][0-9]{0,9}(?::[0-9]{1,5})?(?:[/?#]|$)' or Token matches regex @'^[1-9][0-9]{0,9}(?::[0-9]{1,5})?/'
| extend DecimalHost = extract(@'(?i)^(?:https?://)?([1-9][0-9]{0,9})',1,Token)
| extend NumericIP = tolong(DecimalHost)
| where NumericIP between (1 .. 4294967295)
| extend DecodedIP = format_ipv4(NumericIP)
| project Timestamp, ReportId, DeviceId, DeviceName,FileName, ProcessId,ProcessUniqueId,ProcessCommandLine, DecimalHost, DecodedIP,InitiatingProcessFileName,InitiatingProcessParentFileName, AccountName

The query splits the command into separate words and checks each one. It keeps a word only if it looks like a URL with a number as the host. It also skips any word that comes right after an option (other than --url), because that word is usually the option's value, such as an output path or a timeout. The result shows you the original command next to the decoded address.

That strictness has a price. A bare number with no scheme and no path is skipped. So is a URL that comes straight after a switch such as -s .

2.Confirm the decoded IP in network telemetry

This Logic asks whether the process actually connected to it. It takes successful network events from curl, decodes any number found in the command line, and keeps the row only when the decoded address equals RemoteIP.

DeviceNetworkEvents
| where Timestamp > ago(14d)
| where ActionType == "ConnectionSuccess"
| where InitiatingProcessFileName in~ ("curl.exe", "curl")
| mv-expand Token = split(replace_regex(InitiatingProcessCommandLine, @'[\t\r\n]', ' '),' ') to typeof(string)
| extend Token = trim(@'[\x22\x27]', Token)
| extend Token = trim(@'[\x22\x27]', replace_regex(Token, @'(?i)^--url=', ''))
| extend DecimalHost = extract(@'(?i)^(?:https?://)?([1-9][0-9]{0,9})(?::[0-9]{1,5})?(?:[/?#]|$)',1, Token)
| extend NumericIP = tolong(DecimalHost)
| where NumericIP between (1 .. 4294967295)
| extend DecodedIP = format_ipv4(NumericIP)
| where RemoteIP == DecodedIP
| project Timestamp, ReportId, DeviceId, DeviceName,DecimalHost, DecodedIP, RemoteIP, RemotePort, RemoteUrl,InitiatingProcessFileName,InitiatingProcessId,InitiatingProcessUniqueId,InitiatingProcessCommandLine, InitiatingProcessParentFileName,InitiatingProcessAccountName

The network event already carries the command line of the process that made the connection, so there is no join. If you later want to enrich the result with process creation records, match on DeviceId and the process unique ID. Don’t rely on PID alone, because Windows reuses PIDs.

One catch: proxies and redirects can make the recorded remote IP different from the destination in the command.

3.Hunt for possible Run-key persistence

Writing an IP as a number has nothing to do with persistence. But an attacker could drop a command that contains one into a Windows Run or RunOnce registry value, and that would be worth knowing about.

The query is cautious. It wants an explicit HTTP URL, and it wants the registry data to contain the name of a common shell or network tool. That stops it from treating any random number in the registry as an IP address.

DeviceRegistryEvents
| where Timestamp > ago(14d)
| where ActionType == "RegistryValueSet"
| where RegistryKey endswith @'\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU'
or RegistryKey endswith @'\Microsoft\Windows\CurrentVersion\Run'
or RegistryKey endswith @'\Microsoft\Windows\CurrentVersion\RunOnce'
| where RegistryValueName !~ "MRUList"
| where RegistryValueData has_any ("powershell", "pwsh", "cmd", "curl", "mshta", "wscript", "cscript", "certutil", "bitsadmin", "wget")
| extend Candidates = extract_all(@'(?i)(?:^|[\s\x22\x27(=])(?:https?://)?([1-9][0-9]{0,9})(?::[0-9]{1,5})?/',RegistryValueData)
| mv-expand DecimalHost = Candidates to typeof(string)
| extend NumericIP = tolong(DecimalHost)
| where NumericIP between (1 .. 4294967295)
| extend DecodedIP = format_ipv4(NumericIP)
| project Timestamp, ReportId, DeviceId, DeviceName,RegistryKey, RegistryValueName, RegistryValueData,DecimalHost, DecodedIP,InitiatingProcessFileName,InitiatingProcessCommandLine,InitiatingProcessAccountName

A write to an autorun key is a reason to look closer. It doesn’t prove the entry ever ran. Check that the value is valid and enabled, then look for later execution and matching network activity.

Requiring a scheme and a tool name cuts the noise, but the query then misses scheme-less URLs, encoded commands, and other executables. It also covers only the Run and RunOnce keys shown, not scheduled tasks, services or startup folders.

4.Decimal IPv4 connections from other tools (Hypothesis)

curl is not the only program that can reach out to a URL. This hunt looks for an explicit decimal HTTP URL in the command line of a handful of Windows tools, then requires a successful connection to the decoded IP.

DeviceNetworkEvents
| where Timestamp > ago(14d)
| where ActionType == "ConnectionSuccess"
| where InitiatingProcessFileName in~ ("powershell.exe", "pwsh.exe", "mshta.exe", "wscript.exe","cscript.exe", "certutil.exe", "bitsadmin.exe", "wget.exe")
| mv-expand Token = split(replace_regex(InitiatingProcessCommandLine, @'[\t\r\n]', ' '),' ') to typeof(string)
| extend Token = trim(@'[\x22\x27]', Token)
| extend Token = trim(@'[\x22\x27]',replace_regex(Token, @'(?i)^--url=', ''))
| extend DecimalHost = extract(@'(?i)^(?:https?://)?([1-9][0-9]{0,9})(?::[0-9]{1,5})?(?:[/?#]|$)',1,Token)
| extend NumericIP = tolong(DecimalHost)
| where NumericIP between (1 .. 4294967295)
| extend DecodedIP = format_ipv4(NumericIP)
| where RemoteIP == DecodedIP
| project Timestamp, ReportId, DeviceId, DeviceName,DecimalHost, DecodedIP, RemoteIP, RemotePort, RemoteUrl,InitiatingProcessFileName,InitiatingProcessId,InitiatingProcessUniqueId = tostring(InitiatingProcessUniqueId),InitiatingProcessCommandLine,InitiatingProcessParentFileName,InitiatingProcessAccountName

The network match matters even more in this hunt, because these tools don’t all read a numeric address the same way. A number in the command line only counts once you can see the tool really went to that address.

curl is left out on purpose so this hunt doesn’t repeat Hunt 2. It also misses scheme-less URLs, URLs built at run time and tokens buried inside other syntax.

5.Hexadecimal IPv4 connections from curl

The same single number can be written in hexadecimal. Our address, for example, would be 0x5D5E341D. The incident did not use hex, so treat this hunt as extra coverage and nothing more.

It searches curl command lines for a host that starts with 0x and requires the decoded address to match a successful network event.

DeviceNetworkEvents
| where Timestamp > ago(14d)
| where ActionType == "ConnectionSuccess"
| where InitiatingProcessFileName in~ ("curl.exe", "curl")
| mv-expand Token = split(replace_regex(InitiatingProcessCommandLine, @'[\t\r\n]', ' '),' ') to typeof(string)
| extend Token = trim(@'[\x22\x27]', Token)
| extend Token = trim( @'[\x22\x27]',replace_regex(Token, @'(?i)^--url=', ''))
| extend HexHost = extract(@'(?i)^(?:https?://)?(0x[0-9a-f]{1,8})(?::[0-9]{1,5})?(?:[/?#]|$)',1,Token)
| extend NumericIP = tolong(HexHost)
| where NumericIP between (1 .. 4294967295)
| extend DecodedIP = format_ipv4(NumericIP)
| where RemoteIP == DecodedIP
| project Timestamp, ReportId, DeviceId, DeviceName, HexHost, DecodedIP, RemoteIP, RemotePort, RemoteUrl,InitiatingProcessFileName,InitiatingProcessId,InitiatingProcessUniqueId,InitiatingProcessCommandLine,InitiatingProcessParentFileName,InitiatingProcessAccountName

You got a hit. Now what?

Start at the command and work outward.

  1. Read the command. Is the number really a destination or is it an option value or part of a local path?
  2. Decode and compare. Does the decoded address match a network event from the same process?
  3. Look at the process tree. What launched the process? What ran just before and just after?
  4. Check the files. Was the requested file created or changed? Was it run or loaded later?
  5. Check persistence as its own question. Go through the relevant Run keys, scheduled tasks, services and startup items.
  6. Widen the search. Look across your telemetry for the decimal number, the dotted IP, similar command patterns and any file hashes you have confirmed.

Some admin scripts and test tools do use numeric arguments and odd destinations for honest reasons. If you build an allowlist, keep it narrow and base it on business context you have verified. A process name or an IP address alone is not enough.

Closing

What wd can know from this case is how small the trick is. No packer, no encoded blob, no strange binary. Somebody wrote an address as one number, and that was enough to walk past any search that expects dots.

The number alone told us nothing. It became evidence only after we decoded it and found the same address in the network log, tied to the same process. So decode first, check where the process really went and be honest with yourself about what the evidence proves before you write the report.

When an IP Address Looks Like a Number was originally published in Detect FYI on Medium, where people are continuing the conversation by highlighting and responding to this story.

Introduction to Malware Binary Triage (IMBT) Course

Looking to level up your skills? Get 10% off using coupon code: MWNEWS10 for any flavor.

Enroll Now and Save 10%: Coupon Code MWNEWS10

Note: Affiliate link – your enrollment helps support this platform at no extra cost to you.

Article Link: https://detect.fyi/when-an-ip-address-looks-like-a-number-a2aac799ebca?source=rss----d5fd8f494f6a---4