khr0x40sh / MacroShop

Collection of scripts to aid in delivering payloads via Office Macros. Most are python. See http://khr0x40sh.wordpress.com for details.
MIT License
402 stars 114 forks source link

can't save file more than 64 kb #16

Open praveenyadav1602 opened 7 years ago

praveenyadav1602 commented 7 years ago

after convert .exe to macros through exeinvba.py if output vbs more then 64 kb then we can't save as .xls file.

it always show when i save .xls file Errors were detected while saving (filename). Microsoft excel may be able to save the file by removing or repairing some features. To make the repairs in a new file click Continue. To cancel saving the file click Cancel.

i had tried with excel 2010 and 2013 tried with small .exe file, its working very good.

khr0x40sh commented 7 years ago

I'll take a look at this, but I'm fairly certain I was able to save larger files using MS 97-2003 xls format.

praveenyadav1602 commented 7 years ago

i am also trying with MS 97-2003 .xls format.

on excel 2010 it will save as .xls file but when opening show error "Error occurred while loading this workbook. Do you want to continue loading project?" after choosing yes it failed to execute .exe

and on excel 2013 its failed to save save .xls file. error:

Errors were detected while saving (filename). Microsoft excel may be able to save the file by removing or repairing some features. To make the repairs in a new file click Continue. To cancel saving the file click Cancel.

i am using win 8 in both cases. the problem is only with files that are more than 64 kb.(means where more variable created, more then var0 )

Private Function var1 As String Private Function var2 As String Private Function var3 As String Private Function var4 As String ... ... ...

khr0x40sh commented 7 years ago

I'm still digging into this. I think one potential workaround is to store the data in the workbook fields and then use the macro to extract them from the fields. If I can get around to updating it this week, you'll see a new push soon.

khr0x40sh commented 7 years ago

Also I wonder (maybe more like planning to see if feasible) if I can just write the xls using python myself thereby skipping the the import into Excel step.

As far as additional help, you could always ask @cr4nkapotomus for help

khr0x40sh commented 7 years ago

An update:

It looks like the max length of a string per cell is roughly 32767 (In practice I only saw 32757, so I don't know where the discrepancy lies). In my short tests using the worksheet, it is possible to write a file well over 64k. I was able to write a file of roughly 1,670,607 bytes using 50 rows of 32767 A's, so I'd say this is the way of future releases. I will be pushing an update to github as soon as I get the python right for creating the xls from scratch (yikes!)

praveenyadav1602 commented 7 years ago

thanks.

sevagas commented 6 years ago

For your info, I did manage to make file embedding in VBA work. Even with 1M file like calc. If you are interrested by the code, its in https://github.com/sevagas/macro_pack/blob/master/src/modules/mp_generator.py function embedFile and relies on "WriteBytes" rather than base 64