Open robertstrom opened 2 months ago
Thank you @robertstrom for the kind words and using the module.
It is possible that using the Canary Token generator, it generates a sheet that the DLL that interacts with the writing of the xlsx ends up corrupting it based on fields in the xml that it cannot map.
@dfinke - understood but curious. I can open the Canary Token Excel file in Excel and add content to it in Excel without issue. Any additional thoughts on why that works but Export-Excel does not?
Import-Excel is able to read one of the Canary Token generated files that I have populated with data. I have also validated that the canary token functionality still works after populating it with data via opening it with Excel. Just another data point.
Export-Excel depends on older free version of EPPlus. Off the top of my head, there may be fields it is not exporting or stepping on.
FYI - I tried updating the Excel file using python and I was able to update it but it wiped out the Canary Token functionality. The spreadsheet no longer had the embedded URL. It no longer had the drawings section (as shown in the screenshots) at all.
Which python pkg? So it seems how the canery tokens aspect is created, Excel proper has no issues, 3rd parties do?
it wasn't a specific python package. I just found some code and played with it
create an Excel file
# import pandas
import pandas as pd
# dataframe with Name and Age columns
df = pd.DataFrame({'Name': ['A', 'B', 'C', 'D'], 'Age': [10, 0, 30, 50]})
# create a Pandas Excel writer object using XlsxWriter as the engine
# writer = pd.ExcelWriter('canary.xlsx', engine='xlsxwriter')
writer = pd.ExcelWriter('canary.xlsx', engine='xlsxwriter')
# write data to the excel sheet
df.to_excel(writer, sheet_name='Sheet1', index=False)
# close file
writer.close()
append to an Excel file
# import pandas
import pandas as pd
# new dataframe with same columns
df = pd.DataFrame({'Name': ['I', 'J', 'K', 'L'], 'Age': [1000, 700, 400, 600]})
# read file content
reader = pd.read_excel('canary.xlsx')
# create writer object
# used engine='openpyxl' because append operation is not supported by xlsxwriter
writer = pd.ExcelWriter('canary.xlsx', engine='openpyxl', mode='a', if_sheet_exists="overlay")
# append new dataframe to the excel sheet
df.to_excel(writer, index=False, header=False, startrow=len(reader) + 1)
# close file
writer.close()
So it seems how the canery tokens aspect is created, Excel proper has no issues, 3rd parties do?
Yes, canary token Excel file is created and you can open it in Excel and add data to it (it is blank when the Canary Token Excel file is created) using Excel and the Canary Token functionality is still there.
Modify the Canary Token Excel file using the python code and I can add data to the Excel file but the Canary Token "phone home" (embedded webhook) is gone. Completely removed from the Excel file.
ok. and ImportExcel corrupts the file when you add add to the canary file.
well, you know what they say, canary in the coal mine
That's the one! 🙂
Hello,
Thanks very much for this PowerShell module! It is amazing!
I am currently trying to add data to an existing, blank spreadsheet the was created using the Canary Token generator that can be found here - https://canarytokens.org/nest/generate
Creating one of these gives you a blank spreadsheet that contains a webhook embedded in the spreadsheet. This article has some information on it and links to a Python script that shows the embedded URL - https://neroswarm.com/blog/detecting-canary-tokens-in-office-files. You can also see the information if you use 7-Zip to view the contents of the Excel file.
Using 7-Zip, you can see that this is where the Canary Token information is stored in the Excel file
When you view that file you can see the embedded WebHook URL
I am trying to add content to the blank sheet1 using the code below, where canary.xlsx is the name of the spreadsheet that was generated by the Canary Token website.
When running the commands above I get the error shown below:
I can run the commands above to create a new spreadsheet without issue. I can create a new blank spreadsheet in Excel and then append the data to it without issue but I have found no way to append data to the spreadsheet that is created with the Canary Token embedded in it.
I'm looking for a scripted way to be able to populate the data into a bunch of these Canary Token spreadsheets.
Any assistance in helping me to accomplish this would be very much appreciated.
Thanks very much!