Exetools

Exetools (https://forum.exetools.com/index.php)
-   Community Tools (https://forum.exetools.com/forumdisplay.php?f=47)
-   -   Scylla x64/x86 Imports Reconstruction (https://forum.exetools.com/showthread.php?t=13792)

Newbie_Cracker 09-03-2013 21:24

Today I tried to unpack a DLL and use Scylla, but it did not read its OEP from file/memory.

It seems that Scylla does not read DLL OEP in case of DLL Unpacking.

Am I right?

Carbon 09-04-2013 02:53

@Newbie_Cracker
I don't get it. You need to find the OEP yourself?

@sendersu
I don't think this is a problem. I will think about it. It is because Scylla doesnt pay attention to the api order (like imprec). Scylla is using a different algorithm.

@ahmadmansoor
here: https://github.com/NtQuery/Scylla

Newbie_Cracker 09-04-2013 17:44

Quote:

Originally Posted by Carbon (Post 86588)
@Newbie_Cracker
I don't get it. You need to find the OEP yourself?

In Scylla, like ImpRec, when you choose a process, the OEP is read from PE header and automatically is shown in OEP text box.

Imprec does the same for DLLs, but Scylla does not.

It seems that it reads the ImageBase and ImageSize from memory (I haven't debugged it to check), but it does not read the OEP from the disk/memory.

ahmadmansoor 09-04-2013 21:21

just one thing pls upload the distorm 3.1 folder which u use .
I can't access it .
is there a problem to compile it with v10 instead of v9.0 of VS 2010
Thanks

deepzero 09-05-2013 20:07

where do these new version come from? They are not mentioned on t4u, Scylla's home.

Av0id 09-06-2013 19:57

deepzero, you can get them in t4u download area

Carbon 09-07-2013 00:36

Quote:

Originally Posted by ahmadmansoor (Post 86604)
just one thing pls upload the distorm 3.1 folder which u use .
I can't access it .
is there a problem to compile it with v10 instead of v9.0 of VS 2010
Thanks

Sorry, I don't want to include the distorm project. Just download the latest distorm from the official website and extract it in this folder.
I updated the project files: https://github.com/NtQuery/Scylla/commit/133a8fac409940012ee97d46d4955203bf4421bb

It should work with Visual Studio 2010. I compile it with platform toolset v90 to get WIN XP SP0/1 support. If you compile it with v10, you can execute it only on XP SP2+

@Newbie_Cracker
OK thx, I added it. See attachment.

Carbon 09-27-2013 08:00

1 Attachment(s)
ahmadmansoor had a nice idea for a new IAT search algorithm. It seems that it is very accurate after some tweaks, but takes a little bit longer depending on your computer.

Use the option "advanced iat search" and test it.

If you like to support this project, BTC Address: 1GmVrhWwUhwLohaCLP4SKV5kkz8rd16N8h

Code:

Version 0.9.2

- Pick DLL -> Set DLL Entrypoint
- Advanced IAT Search Algorithm (Enable/Disable it in Options), thanks to ahmadmansoor
- Fixed bug in Options
- Added donate information, please feel free to donate some BTC to support this project


Carbon 02-03-2014 05:54

new options added

Quote:

Version 0.9.4 beta

- direct import scan + fix: 5 byte CALL/JMP, junk byte must be after CALL/JMP
- create new iat in section
- fixed various bugs

Version 0.9.3
- new dll function: iat search
- new dll function: iat fix auto

Carbon 02-05-2014 07:08

1 Attachment(s)
Quote:

Version 0.9.4 Final

- direct import scanner (LEA, MOV, PUSH, CALL, JMP) + fixer with 2 fix methods
- create new iat in section
- fixed various bugs
I really recommend to update due to the bug fixes.

Direct import scanner fix methods:
- Normal: Patch memory with jmp/call only
- Universal: Works with everything, creates a jump table in the scylla section, watch for relocation information in the log file

I also found some weird thing in Windows 7 x64. I don't know yet why this happens:
Quote:

### Windows 7 x64

Sometimes the API kernel32.dll GetProcAddress cannot be resolved, because the IAT has an entry from apphelp.dll
Solution? I don't know

giv 02-05-2014 14:46

The 0.9.4 betra behaved strange on my latest attempts.
On simple unpackmes the resulted dump was invalid....
I home that 0.9.4 final does not have that behaviour.

ahmadmansoor 02-06-2014 09:05

Quote:

Originally Posted by Carbon (Post 89759)
I really recommend to update due to the bug fixes.

Direct import scanner fix methods:
- Normal: Patch memory with jmp/call only
- Universal: Works with everything, creates a jump table in the scylla section, watch for relocation information in the log file
:

I was watch ur update ,My friend Universal import scanner fix is a Good Idea .
but it is limited with some Protector ,in other it is Difficult to handle it .
Let take the Themida/Winlicense : through the unpacked rutine ,it pass through IAT Table rebuild which write the API to the file .here it decide to write the
Quote:

NOP
Jmp xxxxx
or
Call xxxxx
Nop
so this nop it Defined through this rutine ,and I think it is random .
Quote:

00412893 CC int3
00412894 > 90 nop
00412895 .- E9 96287477 jmp msvcr100.__set_app_type
0041289A > 90 nop
0041289B .- E9 60587477 jmp msvcr100._amsg_exit
004128A0 > 90 nop
004128A1 .- E9 3A647477 jmp msvcr100.__wgetmainargs
004128A6 CC int3
+++++++++++++++++++++++++++++++++++++
004129C7 CC int3
004129C8 > 90 nop
004129C9 .- E9 D2567477 jmp msvcr100._exit
004129CE > 90 nop
004129CF .- E9 BCA68177 jmp msvcr100._XcptFilter
004129D4 >- E9 E7567477 jmp msvcr100._cexit
004129D9 . 6F outs dx, dword ptr es:[edi]
004129DA >- E9 A1567477 jmp msvcr100.exit
004129DF 13 db 13
004129E0 > 90 nop
004129E1 .- E9 DA708177 jmp msvcr100._CrtSetCheckCount
004129E6 CC int3
so guessing which NOP is the right to replce for Fix This import will fault by 70%

pls check this Image :
http://postimg.org/image/6fzu4kr8v/
and u will see what I was talking about .I have write a lot of tut on rebuild IAT for Themedi I can send it to u and through this tut u will see when and where the nop is written .
and so on for other Protector ,which each one his privacy .

Quote:

I also found some weird thing in Windows 7 x64. I don't know yet why this happens
can u give example (code or File ) ?

Thanks for ur great work ,pls keep up.

Carbon 02-06-2014 17:41

@giv
feel free to report bugs.

@ahmadmansoor
Try the "universal" direct import fixer (enable in options). It will work with Themida and any other protector.

I don't think I can give an example. It is still weird. It has probably something to do with this https://forum.tuts4you.com/topic/34548-scylla-version-announcements/#entry159332

ahmadmansoor 02-06-2014 17:49

Quote:

Originally Posted by Carbon (Post 89799)
@ahmadmansoor
Try the "universal" direct import fixer (enable in options). It will work with Themida and any other protector.

my friend the example which I gave u in the Picture was universal enable in options :D I will upload the files when back to home .

Quote:

I don't think I can give an example. It is still weird. It has probably something to do with this https://forum.tuts4you.com/topic/34548-scylla-version-announcements/#entry159332
I will check this

Carbon 02-06-2014 18:53

Quote:

Originally Posted by ahmadmansoor (Post 89800)
my friend the example which I gave u in the Picture was universal enable in options :D I will upload the files when back to home .

Now I see there is a bug. You must disable the "normal" fixer otherwise the "universal" will not work. And it is fixed only in the dumped and fixed file. Not in memory.

ahmadmansoor 02-06-2014 19:05

Lol .... my friend I have disable the "normal" fixer too.
I have use the default option when run Scylla first time .
check picture
http://postimg.org/image/umncnodiv/

Carbon 02-06-2014 19:22

Quote:

Originally Posted by ahmadmansoor (Post 89806)
Lol .... my friend I have disable the "normal" fixer too.
I have use the default option when run Scylla first time .
check picture
http://postimg.org/image/umncnodiv/

yes that are the correct settings. Now dump and fix and the direct imports will be resolved.

ahmadmansoor 02-06-2014 19:42

I think I miss something ,so u keep the same size of (jmp or Call) and not make any changes
Quote:

E9 xxxxxx >>>> E9 API
not fixing it to
E9 xxxxxx >>>> FF25 xxxxxx
Ok let me do more checks .

Carbon 02-06-2014 20:08

I change the jmp destination to a jmp table.

Computer_Angel 02-10-2014 21:51

1.Scylla should have option to use PE Header of module on disk just like imprec .
right now, scylla read the pe header from memory and in some case the export directory is destroy make scylla crash.
You could try some target using cryengine sdk such as Warface to get this case/.

2. About apphelp.dll, we could resolve it using plugin to handle it.

deepzero 02-10-2014 22:51

i think scylla is always interested in crash reports, no matter why they happened. :)

Syoma 02-11-2014 05:02

Some feedback
1. It does not remember the last folder used to store dump/fix, but always start from the module home folder.
2. It keeps separate adjacent chunks of functions related to the same module.
3. For dump naming would be better to follow ImpRec behavior: default dump name is module name + suffix.

Feature request
+ Add import manually. Now it can be done using XML editing, but need to recalc offsets, ordinals, etc.
+ Single -Dump & Fix- button :)

Computer_Angel 02-11-2014 17:14

1 Attachment(s)
Quote:

Originally Posted by Carbon (Post 89759)
I also found some weird thing in Windows 7 x64. I don't know yet why this happens:

We could using plugin for apphelp.dll to solve the api. This is my small plugin for Imprec & Scylla.

About scylla crash, I had found that the function ApiReader::parseExportTable is parsing export not correct in some case, the way of calculating functionName = (char*)(addressOfNamesArray[i] + deltaAddress) is not right if the address of names in the differ memory than the exportbuffer cover.

Carbon 02-11-2014 19:24

Quote:

Originally Posted by Computer_Angel (Post 89897)
1.Scylla should have option to use PE Header of module on disk just like imprec .
right now, scylla read the pe header from memory and in some case the export directory is destroy make scylla crash.
You could try some target using cryengine sdk such as Warface to get this case/.

In the options you can choose between reading pe header from disk or from memory. It should work.
Quote:

the way of calculating functionName = (char*)(addressOfNamesArray[i] + deltaAddress) is not right if the address of names in the differ memory than the exportbuffer cover.
Thanks I will fix that.

Quote:

We could using plugin for apphelp.dll to solve the api. This is my small plugin for Imprec & Scylla.
I am more interested in how your plugin works. How do you resolve the functions?
GetProcAddress points to function rva FFF6 from apphelp.dll and this function address is NOT exported by apphelp.dll. This is my problem.

@Syoma
Thanks for the suggestions, I will fix that.

Computer_Angel 02-12-2014 11:37

Quote:

Originally Posted by Carbon (Post 89922)
I am more interested in how your plugin works. How do you resolve the functions?
GetProcAddress points to function rva FFF6 from apphelp.dll and this function address is NOT exported by apphelp.dll. This is my problem.

There're many way.
1.trace into the apphelp.dll function code then you'll get the correct api function by watching some special call,jmp such as call eax, call [eax+const], call [ecx+const], jmp eax.

2. Using debuging symbol of apphelp then we'll get the simillar correct name of api.

I got the same problem with aclayers.dll, but seem it's hard to make a tracer for that. Seem the best way is to hard-code the address value for these dll.

ahmadmansoor 02-12-2014 19:27

I know this is not a good Idea or stupid Idea ,but for unpacker when he work on unpack he can do this :
Quote:

when load apphelp.dll
search for
8B 4D 10 89 08 C7 45 E4 01 00 00 00 C7 45 FC FE FF FF FF 8B 45 E4
search for
75C63011 . 8B4D 10 mov ecx, dword ptr [ebp+0x10]
75C63014 8908 mov dword ptr [eax], ecx >>>> nop this
75C63016 . C745 E4 01000000 mov dword ptr [ebp-0x1C], 0x1
75C6301D > C745 FC FEFFFFFF mov dword ptr [ebp-0x4], -0x2
75C63024 . 8B45 E4 mov eax, dword ptr [ebp-0x1C]

and done . so no need to fix this .

Carbon 03-17-2014 19:43

New version
Quote:

Version 0.9.5

- improved process lister
- improved module lister
- improved dump name
- improved IAT parser
@Computer_Angel
I cannot reproduce the crash, tested with crysis and far cry.

Computer_Angel 03-19-2014 22:03

Quote:

Originally Posted by Carbon (Post 90423)
New version


@Computer_Angel
I cannot reproduce the crash, tested with crysis and far cry.

1.Just test the new version, seem the module lister not list all the module in process.I'll check it more in next day.
2.I'll try to give you the examples about the crash.

Carbon 03-19-2014 22:53

There was a bug with virtual devices...

Computer_Angel 03-20-2014 12:12

Quote:

Originally Posted by Carbon (Post 90452)
There was a bug with virtual devices...

More buggy with lastest release. My binary is on Virtual devices and scylla could not define a correct pathname for it (it show unknow for path). When try to select the process with unknow path ---> crash happen

Carbon 03-20-2014 19:22

1 Attachment(s)
Windows doesn't handle virtual devices like it should :(

This should work now, but the solution is bad...

Computer_Angel 03-22-2014 16:11

1 Attachment(s)
Here's the samples for scylla crash bug. Use Ollydbg2 load the scylla_.exe, then you'll stop at EP. Now using scylla to process the scylla_.exe module and scylla will crash. Hope this will help you :D

ahmadmansoor 03-23-2014 03:01

Hi Carbon :
about Computer_Angel target don't care about it, scylla is the best and it Does not need any fix for handle virtual devices.
this sample is an tricky Target :rolleyes: it write false size for IMAGE_EXPORT_DIRECTORY which make it very very big so can't handle it with
bufferExportTable = new BYTE[readSize];
so Computer_Angel it is as an anti scylla (or other IAT re builder ) technique ;) .
Quote:

10001036 |. 50 push eax ; /pOldProtect
10001037 |. 6A 40 push 0x40 ; |NewProtect = PAGE_EXECUTE_READWRITE
10001039 |. 8B3E mov edi, dword ptr [esi] ; |
1000103B |. 6A 04 push 0x4 ; |Size = 0x4
1000103D |. 56 push esi ; |Address
1000103E |. FF15 0>call near dword ptr [<&KERNEL32.VirtualP>; \VirtualProtect
10001044 |. E8 AE0>call scyllacr.100010F7
10001049 |. 0FB6C0 movzx eax, al
1000104C |. 69C0 0>imul eax, eax, 0x1010101
10001052 |. 8906 mov dword ptr [esi], eax
10001054 |. 8946 0>mov dword ptr [esi+0x4], eax <<<<<< very bad
Computer_Angel just one thing ,pls where u get like this targets ,every time u surprise us with this kind of targets ,I work with a lot of targets never get my hand on targets like which u bring it to us .....
Computer_Angel :cool:

Computer_Angel 03-23-2014 08:55

Ahmadmansoor , i get this problem when unpack warface game.

Carbon 03-24-2014 05:38

1 Attachment(s)
Thanks for the file Computer_Angel and thanks for the help ahmadmansoor.

I added an option to read the export table always from disk. This is slower than reading it from the target process. I guess this is a rare case, so people should only enable it if needed.

Quote:

Version 0.9.6

- improved iat search
- fixed bug in api resolve engine
- new option: parse APIs always from disk -> slower, useful against pe header modifications

Syoma 03-24-2014 20:45

Very good release )
Could you please collapse all nodes after chunks merge at the end?
Also, if possible add option to set image header flag "relocations stripped" on Dump.
May be also option to automatically save tree on Dump as ModuleName-Tree.xml

Syoma 03-24-2014 21:17

Bug report:
Missed entries in the chunks. Check image.
http://rghost.ru/53312007/image.png

Carbon 03-24-2014 23:33

Quote:

Originally Posted by Syoma (Post 90513)
Bug report:
Missed entries in the chunks. Check image.
http://rghost.ru/53312007/image.png

Thanks for the report. Are you sure that this is a mistake? What entry did scylla miss? Can you please show me the spot in olly with dump view "Long -> address with ascii dump".

Syoma 03-25-2014 00:00

Yes, I am sure it is mistake. The missed import entries are data-related, not functions. Like __declspec(dllexport) int i; and the same for structures instances.

Also, the same problem with msvcr90.dll import
150 __CppXcptFilter dd ?
154 _adjust_fdiv dd ? // <<----- this one was missed in chunk
158 _amsg_exit dd ?

I do not use Olly. So, not sure what you asking for.

Carbon 03-25-2014 00:30

1 Attachment(s)
Thanks, I forgot that data exports exist... this should fix it.


All times are GMT +8. The time now is 04:41.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX