23.03.2013 Views

Quick introduction to reverse engineering for beginners

Quick introduction to reverse engineering for beginners

Quick introduction to reverse engineering for beginners

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Yes. getenv_s() 5 function is Microsoft security-enhanced version of getenv() 6 .<br />

There are also some MFC string manipulations.<br />

Lots of other environment variables are checked as well. Here is a list of all variables being checked and<br />

what SAPGUI could write <strong>to</strong> trace log when logging is turned on:<br />

DPTRACE “GUI-OPTION: Trace set <strong>to</strong> %d”<br />

TDW_HEXDUMP “GUI-OPTION: Hexdump enabled”<br />

TDW_WORKDIR “GUI-OPTION: working direc<strong>to</strong>ry ‘%s ´ ’’<br />

TDW_SPLASHSRCEENOFF “GUI-OPTION: Splash Screen Off” / “GUI-OPTION: Splash Screen On”<br />

TDW_REPLYTIMEOUT “GUI-OPTION: reply timeout %d milliseconds”<br />

TDW_PLAYBACKTIMEOUT “GUI-OPTION: PlaybackTimeout set <strong>to</strong> %d milliseconds”<br />

TDW_NOCOMPRESS “GUI-OPTION: no compression read”<br />

TDW_EXPERT “GUI-OPTION: expert mode”<br />

TDW_PLAYBACKPROGRESS “GUI-OPTION: PlaybackProgress”<br />

TDW_PLAYBACKNETTRAFFIC “GUI-OPTION: PlaybackNetTraffic”<br />

TDW_PLAYLOG “GUI-OPTION: /PlayLog is YES, file %s”<br />

TDW_PLAYTIME “GUI-OPTION: /PlayTime set <strong>to</strong> %d milliseconds”<br />

TDW_LOGFILE “GUI-OPTION: TDW_LOGFILE ‘%s ´ ’’<br />

TDW_WAN “GUI-OPTION: WAN - low speed connection enabled”<br />

TDW_FULLMENU “GUI-OPTION: FullMenu enabled”<br />

SAP_CP / SAP_CODEPAGE “GUI-OPTION: SAP_CODEPAGE ‘%d ´ ’’<br />

UPDOWNLOAD_CP “GUI-OPTION: UPDOWNLOAD_CP ‘%d ´ ’’<br />

SNC_PARTNERNAME “GUI-OPTION: SNC name ‘%s ´ ’’<br />

SNC_QOP “GUI-OPTION: SNC_QOP ‘%s ´ ’’<br />

SNC_LIB “GUI-OPTION: SNC is set <strong>to</strong>: %s”<br />

SAPGUI_INPLACE “GUI-OPTION: environment variable SAPGUI_INPLACE is on”<br />

Settings <strong>for</strong> each variable are written <strong>to</strong> the array via pointer in EDI register. EDI is being set be<strong>for</strong>e that<br />

function call:<br />

.text:6440EE00 lea edi, [ebp+2884h+var_2884] ; options here like +0x15<br />

...<br />

.text:6440EE03 lea ecx, [esi+24h]<br />

.text:6440EE06 call load_command_line<br />

.text:6440EE0B mov edi, eax<br />

.text:6440EE0D xor ebx, ebx<br />

.text:6440EE0F cmp edi, ebx<br />

.text:6440EE11 jz short loc_6440EE42<br />

.text:6440EE13 push edi<br />

.text:6440EE14 push offset aSapguiS<strong>to</strong>ppedA ; "Sapgui s<strong>to</strong>pped after<br />

commandline interp"...<br />

.text:6440EE19 push dword_644F93E8<br />

.text:6440EE1F call FEWTraceError<br />

Now, can we find “data record mode switched on” string? Yes, and here is the only reference in function<br />

CDwsGui::PrepareInfoWindow(). How do I know class/method names? There is a lot of special debugging<br />

calls writing <strong>to</strong> log-files like:<br />

.text:64405160 push dword ptr [esi+2854h]<br />

.text:64405166 push offset aCdwsguiPrepare ; "\nCDwsGui::<br />

PrepareInfoWindow: sapgui env"...<br />

.text:6440516B push dword ptr [esi+2848h]<br />

5 http://msdn.microsoft.com/en-us/library/tb2sfw2z(VS.80).aspx<br />

6 Standard C library returning environment variable<br />

186

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!