Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Olevba not expecting optional ProjectCompatVersion record #833

Closed
Beakerboy opened this issue Nov 14, 2023 · 9 comments · Fixed by #723
Closed

Olevba not expecting optional ProjectCompatVersion record #833

Beakerboy opened this issue Nov 14, 2023 · 9 comments · Fixed by #723
Assignees
Milestone

Comments

@Beakerboy
Copy link

Beakerboy commented Nov 14, 2023

Affected tool:
olevba

Describe the bug
MS-OVBA defines an optional attribute in the Dir Stream called the ProjectCompatVersion record. If this record is present in the dir stream, I receive the following error:

Type: OLE
WARNING  invalid value for PROJECTLCID_Id expected 0002 
got 004A
WARNING  invalid value for PROJECTLCID_Lcid expected 040
9 got 0003
WARNING  invalid value for PROJECTLCIDINVOKE_Id expected
 0014 got 0002
WARNING  invalid value for PROJECTCODEPAGE_Id expected 0
003 got 0014
WARNING  invalid value for PROJECTCODEPAGE_Size expected
 0002 got 0004
WARNING  invalid value for PROJECTNAME_Id expected 0004 
got 0000
ERROR    PROJECTNAME_SizeOfProjectName value not in rang
e [1-128]: 131075
ERROR    Error in _extract_vba

How To Reproduce the bug
Version 0.0.10 of this file has the optional record, version 0.0.11 does not.

wget https://github.com/Beakerboy/VBA-CI-CD-Test/releases/download/0.0.10/Addin.xlam
mv Addin.xlam Addin.0.0.10.zip
unzip Addin.0.0.10.zip -d Addin.0.0.10
olevba -a Addin.0.0.10/xl/vbaProject.bin

Expected behavior
The file should parse fine with the presence of the optional record.

Version information:

  • OS: Linux
  • OS version: Debian 11
  • Python version: 3.11.2
  • oletools version: 0.60.1
@decalage2 decalage2 self-assigned this Nov 15, 2023
@decalage2 decalage2 added this to the Next Release milestone Nov 15, 2023
@decalage2
Copy link
Owner

Hi, I think this issue should be fixed with PR #723, but I haven't had time to test it yet.

@Beakerboy
Copy link
Author

Beakerboy commented Nov 15, 2023

@decalage2 Thanks! The 0.0.11 version of that Addin seems to pass the examination of olevba, but Excel complains that:

the file format or file extension is not valid.
Verify that the file has not been corrupted and that the file extension matches the format of the file.

let me know if you can think of any other places in the vbaProject.bin file that errors could be hiding.

@decalage2
Copy link
Owner

The error shown above is now fixed thanks to PR #723, so I close this issue.

However, there seems to be another XML parsing issue with your XLAM file: xml.etree.ElementTree.ParseError: XML declaration not well-formed: line 1, column 49

@decalage2 decalage2 modified the milestones: Next Release, oletools 0.60 Jan 31, 2024
@decalage2 decalage2 linked a pull request Jan 31, 2024 that will close this issue
@Beakerboy
Copy link
Author

Thanks for the update. What program is displaying that xml error? I’ve inspected the XML files and they all appear to start with:

<?xml version="1.0” encoding=“UTF-8” standalone=“yes”?>

So is there a problem with the “yes”? Does it indicate which XML file has the issue?

@decalage2
Copy link
Owner

I don't know what the actual problem is, but I get this error when parsing your latest releases of addin.xlam up to 0.0.14 with olevba. The error comes from the ElementTree XML parser, not from olevba itself.

@Beakerboy
Copy link
Author

The header for olevba.py says the supported formats include Excel 97-2003 (.xls), Excel 2007+ (.xlsm, .xlsb).

xlam is not listed, Do excel addins have a format that olevba cannot handle?

@decalage2
Copy link
Owner

AFAIK, XLAM is very similar to an Excel file with macros (XLSM), so normally olevba works fine. In your case, there seems to be a slight XML issue somewhere. Does your file work with Excel?

@Beakerboy
Copy link
Author

Beakerboy commented Jan 31, 2024

No it does not, which is why I was investigating it with olevba and found the earlier error. I'll see if I can find out which line in olevba is raising the exception and add a try/except block to isolate the issue in my file.

@decalage2
Copy link
Owner

The issue is in the file _rels/.rels, there is standalone=true instead of yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants