Skip to main content

RIG Exploit Kit Shellcode analysis

RIG Exploit Kit Shellcode analysis


Brad published a traffic analysis exercise which I had a quick look at and felt that I wanted to take it to the next level so I started looking at how to decode the payload delivered by the exploit kit.

I get the shellcode from the Flash exploit as its provided as a hex-encoded string starting with "90909090" (NOP):

An easy way to go is to create an executable from the shellcode utilizing Shellcode2Exe to be able to step through it in OllyDbg.

Taking the step into shellcode
Loading it up in Olly, it will start with a loop which decodes the payload URL using XOR as seen below. The key can be found by inspecting ESI when first hitting the loop and the encoded data can be found by inspecting EDI.
After decoding:
The decoding loop will continue until the decoded byte is "!" (0x21), the reason will be explained later in the post under "Multiple payloads".

The shellcode uses URLDownloadToCacheFileA to download the payload. Should the payload be successfully downloaded, it will be opened with CreateFileA and read with ReadFile into memory allocated using VirtualAlloc.

After reading the file it will be decrypted using RC4 cipher with a key defined in the shellcode. I recommend reading the post from VRT on how to recognize RC4 when debugging. This is the function found in the shellcode:
Inspecting EDI when hitting the above lines its found to have the following content:
EDI is pointing to the first byte of the key and EBP holds the key length which is 5 giving the key m3S4V.

At this point its possible to let the shellcode run until CloseHandle is called and the decoded payload has been written back to disk or write a script for decoding the payload extracted from the PCAP. A small implementation of the RC4 cipher can be found here (Python).

Multiple payloads
What is the most interesting thing about the shellcode is that it carries more functionality than isnt used. The shellcode is used to download one payload, but the shellcode supports multiple payloads.

After calling CreateProcessA, the shellcode will step through the recently used URL looking for the end of the string (0x00), and comparing the next byte with "!" (0x21). If its true, the shellcode will end otherwise it will start over with a new payload.
An example of URL-list would look like this:
<url1>0x00<url2>0x00<urlN>0x0021


Conclusion of sorts
RIGs shellcode have the capability to download and execute multiple payloads which are encrypted using RC4 (5 byte key). The URL-list is encoded using XOR (5 byte key).

API-calls used in the shellcode (in order of first call):
- LoadLibraryA
- URLDownloadToCacheFileA
- CreateFileA
- VirtualAlloc
- ReadFile
- SetFilePointer
- WriteFile
- VirtualFree
- CloseHandle
- CreateProcessA

You can find the hex-encoded shellcode on [pastebin].

download file now

Popular posts from this blog

Ragnos1997 Low Specs Patches for low PC Download

Ragnos1997 Low Specs Patches for low PC Download Ragnos1997 Low Specs Patches for Low PC Full Download "Let your system breathe, and enjoy even the latest games on your low end hardware. Only with Low Specs Experience�" Which games are affected ? ALAN WAKE ALAN WAKE�S AMERICAN NIGHTMARE ALIEN: ISOLATION ALIEN: COLONIAL MARINES 7 DAYS TO DIE AMERICAN TRUCK SIMULATOR ANNO 2205 ARMA III ASSASSIN�S CREED ASSASSIN�S CREED II ASSASSIN�S CREED BROTHERHOOD ASSASSIN�S CREED REVELATIONS ASSASSIN�S CREED III ASSASSIN�S CREED III LIBERATION HD ASSASSIN�S CREED IV BLACK FLAG ASSASSIN�S CREED UNITY ASSASSIN�S CREED ROGUE ASSASSIN�S CREED SYNDICATE BATMAN ARKHAM ORIGINS BATMAN ARKHAM ORIGINS BATTLEFIELD BAD COMPANY 2 BATTLEFIELD 3 BATTLEFIELD 4 BATTLEFIELD HARDLINE BATTLEFIELD 1 BIOSHOCK INFINITE BORDERLANDS BORDERLANDS 2 BORDERLANDS THE PRE-SEQUEL CALL OF DUTY BLACK OPS CALL OF DUTY BLACK OPS II CALL OF DUTY BLACK OPS III CALL OF DUTY GHOSTS CALL OF DUTY ADVANCED WARFARE CALL OF DUTY INFIN...

TDATS fourth birthday festive greetings to you all!

TDATS fourth birthday festive greetings to you all! No music here....just a thanks to all the people who have been following this blog, four years down the line and I am still finding new ideas and receiving helpful pointers from readers who are often more informed than me....so thanks to you all. Please reply here or email me with any tips and ideas for the blog....you can also join in and contribute to TDATS news in the fb group.....I have some new ideas in the works....the next post in a few days, in time to be a Christmas present to you all, will be a revealing interview and story regarding a great band that I dont think has been spotlighted anywhere as yet.....and I have more plans to do that kind of thing next year....there are plenty more themes in the works....any advice that readers would like to offer on South-East Asia, East-European and latin american bands would be gladly followed up and if you can think of any other themes that will go down well here let me know! Happy ho...

Ramayana Soul Sabdatanmantra � �地獄 Scattered Purgatory God of Silver Grass

Ramayana Soul Sabdatanmantra � �地獄 Scattered Purgatory God of Silver Grass Reviewed by Nathan Ford There are few who read this rag who would doubt that we place Kikagaku Moyo at the very pinnacle of the current Japanese psychedelic scene. That being the case, its not unusual at all to discover that Guruguru Brain, the label run by Kikagaku Moyos Tomoyuki Katsurada is a veritable treasure trove of adventurous psychedelia, inhabited by names known to few in the Western world. Their first release was a wonderful and essential sampler of modern Japanese psychedelia which can still be downloaded for free here, but its two more recent releases that we concern ourselves with today. Ramayana Soul is first on the turntable, and while the band are actually Indonesian, its obvious why Katsuradas interest was peaked. "Sabdatanmantra" is a joyous wonder that perfectly illustrates the singular way in which Eastern psychedelia embraces free form spontaneity without sacrificing a tune, or in...