IPFuscation is a technique that allows for IP addresses to be represented in hexadecimal, octal, or a combination, instead of the decimal encoding that we are used to.
Hexadecimal + Decimal + Octal:
Hexadecimal with period symbol:
Hexadecimal with 0 padding:
Octal with period symbol:
Octal with 0 padding:
As we can see there's a bunch of ways you can ping the same IP. For a moment, I wondered if this was just how Ping worked. However, given that this works with
OpenURL, I decided to try it with Cobalt Strike!
I wrote a script that automatically outputs a set of known formats for the same IP address that you specify. Hopefully will be useful for some people!
python .\ipfuscator.py 127.0.0.1IPFuscatorAuthor: Vincent Yiu (@vysecurity)https://www.github.com/vysec/IPFuscatorVersion: 0.1.0IP Address: 127.0.0.1Decimal: 2130706433Hexadecimal: 0x7f000001Octal: 017700000001Full Hex: 0x7f.0x0.0x0.0x1Full Oct: 0177.0.0.01Random Padding:Hex: 0x000000000000000007f.0x00000000000000000000.0x0000000000000000000.0x0000000000000000000001Oct: 0000000000000000000000000177.000000000000000.0000000000000000000000.0000000000000000000000000000001Random base:#1: 0x7f.0x0.0.1#2: 127.0.0x0.0x1#3: 0177.0x0.0.1#4: 0x7f.0.0.1#5: 127.0x0.0x0.1Random base with random padding:#1: 0x0000000007f.0.0000000000.00000000000001#2: 0x000000000007f.0x0000000000000000000000.0x00000000000000.0x00000000001#3: 00000000000000000000000177.0x00000000.000000000000000.00000000000000000000000001#4: 000000000000000220.127.116.11#5: 127.0000000000000000000000.00000000000000.0x0000000000001
Although I rarely use IP addresses compared to hostnames when it comes to connecting to resources, we know for a fact that many threat actors do. In some cases you may want to resort to using IP addresses and this technique can add a bit of flavor to the mix.
To use this technique in Cobalt Strike, you simply create a listener like you normally would. Let's say my IP was
18.104.22.168, run IPFuscator as shown below:
You can immediately take this information and use any of these representations in your listener address. For example:
Generate a payload as you would normally, and it all works fantastically!
You could even mix it up a bit:
I actually wrote a Cobalt Strike Aggressor Script to automatically convert an IP that you can issue with the
ping command that will convert and use ping with a hexadecimal equivalent IP. If you want to use this you can obtain this script in my Aggressor repository. This was released back in 2017.
IPFuscation is not an advanced technique. However, it can be used to:
potentially break regex rules for command line logging looking for IP addresses. Eg. when you issue a command such as
obfuscate previously unobfuscated / unencrypted cleartext strings to C2 locations within the payload
According to inphosys on Reddit, the proxy sees the regular decimal IP address notation:
To keep it simple, make the use of IPs cool again! :)