floss는 strings의 상위호환?

floss로 스택 문자열 찾기

By Hong

strings

strings라는 툴을 사용하면 파일 안에 문자열들을 출력하는게 가능하다.

forFLOSS.exe라는 프로그램으로 확인해보자.

프로그램을 실행하면 다음과 같은 문자열이 출력된다.

>forFLOSS.exe
Hello World!

그럼 Hello World!라는 문자열이 프로그램 안에 적혀있다는 것을 확실히 알 수 있으나,

말웨어를 심는 공격자 입장에서는 작성한 내용을 그리 간단하게 들키고 싶지 않을 것이다.

그래서 몇몇 공격자들은 난독화를 하기 위해 일부러 문자열이 아닌 한글자 한글자 스택형식으로 작성하는 방법을 사용하기도 한다.

helloworld

이런식으로 작성하면 strings로 확인해봐도 문자열이 나타나지 않게 된다.

예를 들어서 아래의 출력은 forFLOSS.exe라는 프로그램을 strings로 검사했을 때의 결과물이다.

strings -n 10 forFLOSS.exe

!This program cannot be run in DOS mode.
<ItC<Lt3<Tt#<h
PP9E u:PPVWP
__thiscall
__fastcall
__vectorcall
__restrict
__unaligned
`local static guard'
`vbase destructor'
`vector deleting destructor'
`default constructor closure'
`scalar deleting destructor'
`vector constructor iterator'
`vector destructor iterator'
`vector vbase constructor iterator'
`virtual displacement map'
`eh vector constructor iterator'
`eh vector destructor iterator'
`eh vector vbase constructor iterator'
`copy constructor closure'
`udt returning'
`local vftable'
`local vftable constructor closure'
`omni callsig'
`placement delete closure'
`placement delete[] closure'
`managed vector constructor iterator'
`managed vector destructor iterator'
`eh vector copy constructor iterator'
`eh vector vbase copy constructor iterator'
`dynamic initializer for '
`dynamic atexit destructor for '
`vector copy constructor iterator'
`vector vbase copy constructor iterator'
`managed vector copy constructor iterator'
`local static thread guard'
operator ""
operator co_await
operator<=>
 Type Descriptor'
 Base Class Descriptor at (
 Base Class Array'
 Class Hierarchy Descriptor'
 Complete Object Locator'
`anonymous namespace'
Aapi-ms-win-core-fibers-l1-1-1
api-ms-win-core-synch-l1-2-0
FlsGetValue
FlsSetValue
InitializeCriticalSectionEx
mscoree.dll
CorExitProcess
Aapi-ms-win-core-datetime-l1-1-1
api-ms-win-core-file-l1-2-2
api-ms-win-core-localization-l1-2-1
api-ms-win-core-localization-obsolete-l1-2-0
api-ms-win-core-processthreads-l1-1-2
api-ms-win-core-string-l1-1-0
api-ms-win-core-sysinfo-l1-2-1
api-ms-win-core-winrt-l1-1-0
api-ms-win-core-xstate-l2-1-0
api-ms-win-rtcore-ntuser-window-l1-1-0
api-ms-win-security-systemfunctions-l1-1-0
ext-ms-win-ntuser-dialogbox-l1-1-0
ext-ms-win-ntuser-windowstation-l1-1-0
api-ms-win-appmodel-runtime-l1-1-2
AreFileApisANSI
CompareStringEx
LCMapStringEx
LocaleNameToLCID
AppPolicyGetProcessTerminationMethod
dddd, MMMM dd, yyyy
dddd, MMMM dd, yyyy
         (((((                  H

 !"#$%&'()*+,-./0123456789:;<=>?@abcdefghijklmnopqrstuvwxyz[\]^_`abcdefghijklmnopqrstuvwxyz{|}~


 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~
...
FindNextFileW
IsValidCodePage
MultiByteToWideChar
WideCharToMultiByte
GetEnvironmentStringsW
FreeEnvironmentStringsW
SetEnvironmentVariableW
SetStdHandle
GetStringTypeW
GetProcessHeap
FlushFileBuffers
GetConsoleOutputCP
GetConsoleMode
GetFileSizeEx
SetFilePointerEx
HeapReAlloc
CloseHandle
CreateFileW
WriteConsoleW
DecodePointer
KERNEL32.dll

abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ

abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level='asInvoker' uiAccess='false' />
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>
1#1*121:1B1N1W1\1b1l1v1
5#5)5/5D5Y5`5f5x5
757[7d7j7}7I8i8s8
869?9D9W9k9p9
;!;*;Y;b;k;y;
2:2N2j2t2~2
3 4;4@4E4`4m4v4{4
5*5/545U5e5
;(;4;@;N;^;s;
<"<6<?<Z?b?i?
2M3Q3U3Y3]3a3e3i3`8g8
3R3]3H5R5k5u5
9 989=9I9N9b91:8:J:^:f:p:y:
;T;`;e;k;p;x;~;
9!9M9S9e9v9{9
;.;3;8;U;y;
<)<.<3<N<]<h<m<r<
?#?4?I?S?v?
7"717;7H7R7b7
;#;';-;1;7;;;E;X;a;|;
818C8U8g8y8
0=1B1G1L1U1
6Y6a6i6q6y6
1 1$1(1,10141@1D1H1`1d1h1p1x1
2 2(20282@2H2P2X2`2h2p2x2
3 3(30383@3H3P3X3`3h3p3x3
4 4(40484@4H4P4X4`4h4p4x4
1 1$1(1,10141<1@1D1H1L1P1T1X1d1l1t1x1|1
3 3$3(3,3034383<3 8$8(8,8084888<8@8D8H8L8P8T8X8\8
9 9$9(9,9094989<9@9D9H9L9P9\9`9d9h9l9p9t9x9|9
4$4,444<4D4L4T4\4d4l4t4|4
5$5,545<5D5L5T5\5d5l5t5|5
6$6,646<6D6L6T6\6d6l6t6|6
7$7,747<7D7L7T7\7d7l7t7|7
8$8,848<8D8L8T8\8d8l8t8|8
9$9,949<9D9L9T9\9d9l9t9|9
:$:,:4:<:D:L:T:\:d:l:t:|:
5 5(50585@5H5P5X5`5h5p5x5
6 6(60686@6H6P6X6`6h6p6x6
7 7(70787@7H7P7X7`7h7p7x7
8 8(80888@8H8P8X8`8h8p8x8
9 9(90989@9H9P9X9`9h9p9x9
: :(:0:8:@:H:P:X:`:h:p:x:
; ;(;0;8;@;H;P;X;`;h;p;x;
9$9,949<9D9L9T9\9d9l9t9|9
1 7$7(7,7074787<7@7D7P7T7X7\7`7d7h7l7

내용이 굉장히 길지만 분명히 들어있을 Hello world라는 문자열이 없는 것을 알 수 있다.

Floss

이런 난독화를 돌파하기 위한 툴이 floss라는 툴 되시겠다.

이것을 이용하면 스택으로 난독화된 문자열을 찾아내는 게 가능하다.

>floss forFLOSS.exe

---------------------------
| FLOSS STACK STRINGS (1) |
---------------------------
Hello World!

---------------------------
| FLOSS TIGHT STRINGS (0) |
---------------------------

-----------------------------
| FLOSS DECODED STRINGS (0) |
-----------------------------

프로그램을 실행한 후 결과물을 확인해보면, 스택 스트링 부분에 Hello World! 문자열이 제대로 포착된 것을 알 수 있다.

이처럼 Floss라는 툴을 이용하면 strings로는 찾을 수 없는 난독화를 돌파하는 것이 가능하다.

정리

strings로 검출되지 않은 문자열을 floss를 사용하면 찾아낼지도 모른다.

난독화를 뚫기 위한 한 방법.

Share: X (Twitter) Facebook LinkedIn