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

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...

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...

The Jazz Composers Orchestra Communication 1965

The Jazz Composers Orchestra Communication 1965 De entre los distintos movimientos vanguardistas musicales norteamericanos, habidos en la d�cada de los 60s, surgi� una revitalizaci�n que favoreci� al jazz experimental, o tambi�n llamado ��free jazz��. Una oleada de free jazz que dar�a resurgimiento al jazz vanguardista en los Estados Unidos, impulsada por el estadounidense Bill Dixon, un trompetista de jazz, artista y profesor de m�sica, quien en 1964 organizar�a el festival de jazz ��October Revolution��, en el �Cellar Caf� de Nueva York. Este evento, de inesperada popularidad y repercusi�n, tendr�a un impacto tal que dar�a pie a nuevos movimientos y asociaciones concernientes al g�nero y ayudar�a, junto a otros factores, a establecer al free jazz como una nueva parte de la tradici�n del g�nero. En realidad este ser�a el segundo surgimiento del free jazz en los Estados Unidos. Originalmente la primer oleada de ��jazz contracultural�� se dio a finales de los a�os 50s, m�s espec�ficamen...