faustf Posted November 14, 2019 Posted November 14, 2019 hi guys i try to read a file .p7m , if i open it with notepad or notepad++ , i can see all xml inside, ofcurse the cript-sign no , but for me is important read xml part inside of them , but when i try to read whit fileopen etc.. returnme a 0x30821D5F06092A864886F70D010702A0821D5030821D4C020101310F300D060960864801650304020105003082118606092A8648....... some time know how resolve it ? #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <File.au3> local $Path = @scriptdir &"\file.p7m" Local $sLFattXmlP7m = _True_ReadFile($Path 0) Func _True_ReadFile($sFilePath, $attribute) Local $hFileOpen = FileOpen($sFilePath, $attribute) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.") Return False EndIf Local $sFileRead = FileRead($hFileOpen) FileClose($hFileOpen) Return $sFileRead EndFunc ;==>_True_ReadFile
Developers Jos Posted November 14, 2019 Developers Posted November 14, 2019 What have you done to debug? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
seadoggie01 Posted November 14, 2019 Posted November 14, 2019 (edited) Check what encoding Notepad++ is using and set the proper FileOpen mode parameter based on that. Edit: Notepad++ literally has a button on the top menu that says "Encoding" click it 😐 Edited November 14, 2019 by seadoggie01 All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types
faustf Posted November 14, 2019 Author Posted November 14, 2019 how can Check what encoding Notepad++ ? 2 minutes ago, Jos said: What have you done to debug? i try to rename a p7m in xml , for look if have the same problem and yes i have and start to googeling
Nine Posted November 14, 2019 Posted November 14, 2019 https://filext.com/file-extension/P7M “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
faustf Posted November 14, 2019 Author Posted November 14, 2019 3 minutes ago, Nine said: https://filext.com/file-extension/P7M tel me this It's a text file, that's all we have found out. The file has a few characteristics of a CAT (Microsoft Security Catalog (DER encoded)) or DER (DER encoded X509 Certificate) file. ⓘ
Musashi Posted November 14, 2019 Posted November 14, 2019 1 hour ago, faustf said: how can Check what encoding Notepad++ In general, you can also determine the encoding of a file with : #include <FileConstants.au3> Global $g_sFullFilename $g_sFullFilename = @ScriptDir & '\file.p7m' ConsoleWrite('> ==> ' & $g_sFullFilename & @CRLF) ConsoleWrite('< =====> ' & _GetEncoding($g_sFullFilename) & @CRLF) Func _GetEncoding($sFilename) Local $iEncoding, $sReturnVal $iEncoding = FileGetEncoding($sFilename) Switch $iEncoding Case $FO_UTF16_LE $sReturnVal = 'UTF16 Little Endian' Case $FO_UTF16_BE $sReturnVal = 'UTF16 Big Endian' Case $FO_UTF8 $sReturnVal = 'UTF8 (with BOM)' Case $FO_UTF8_NOBOM $sReturnVal = 'UTF8 (without BOM)' Case $FO_ANSI $sReturnVal = 'ANSI (containing char > 127 and < 255)' Case $FO_UTF16_LE_NOBOM $sReturnVal = 'UTF16 Little Endian (without BOM)' Case $FO_UTF16_BE_NOBOM $sReturnVal = 'UTF16 Big Endian (without BOM) ' Case Else $sReturnVal = 'other ... ' EndSwitch Return($sReturnVal) EndFunc ;==>_GetEncoding but that probably won't help you in this case. "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
mLipok Posted November 14, 2019 Posted November 14, 2019 You should take a look in my cert util UDF Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24
faustf Posted November 15, 2019 Author Posted November 15, 2019 13 hours ago, Musashi said: #include <FileConstants.au3> Global $g_sFullFilename $g_sFullFilename = @ScriptDir & '\file.p7m' ConsoleWrite('> ==> ' & $g_sFullFilename & @CRLF) ConsoleWrite('< =====> ' & _GetEncoding($g_sFullFilename) & @CRLF) Func _GetEncoding($sFilename) Local $iEncoding, $sReturnVal $iEncoding = FileGetEncoding($sFilename) Switch $iEncoding Case $FO_UTF16_LE $sReturnVal = 'UTF16 Little Endian' Case $FO_UTF16_BE $sReturnVal = 'UTF16 Big Endian' Case $FO_UTF8 $sReturnVal = 'UTF8 (with BOM)' Case $FO_UTF8_NOBOM $sReturnVal = 'UTF8 (without BOM)' Case $FO_ANSI $sReturnVal = 'ANSI (containing char > 127 and < 255)' Case $FO_UTF16_LE_NOBOM $sReturnVal = 'UTF16 Little Endian (without BOM)' Case $FO_UTF16_BE_NOBOM $sReturnVal = 'UTF16 Big Endian (without BOM) ' Case Else $sReturnVal = 'other ... ' EndSwitch Return($sReturnVal) EndFunc ;==>_GetEncoding yea return me < =====> other ... +>11:05:09 AutoIt3.exe ended.rc:0 +>11:05:09 AutoIt3Wrapper Finished. >Exit code: 0 Time: 3.914
Musashi Posted November 15, 2019 Posted November 15, 2019 4 minutes ago, faustf said: where i find your cert util UDF ? Support topic : https://www.autoitscript.com/forum/topic/184937-certutil-udf-support-topic/ Download : https://www.autoitscript.com/forum/files/file/421-certutil-udf/ "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
faustf Posted November 15, 2019 Author Posted November 15, 2019 another questions , i try to read a file with cmd type , and i can read like in notepad i try to crete by autoit and run Func _CMD_Type($path) Local $iPID =Run(@ComSpec & " /c " &'type '&$path, "", @SW_HIDE ,$STDIN_CHILD + $STDOUT_CHILD) Sleep(1000) ;ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : StdoutRead($iPID) = ' & StdoutRead($iPID) & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console ;Sleep(1000) ;StdinWrite($iPID, "list disk" & @CRLF) ;StdinWrite($iPID, "Exit" & @CRLF) ProcessWaitClose($iPID) ;Sleep(1000) ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead. Local $sOutput = StdoutRead($iPID) ConsoleWrite($sOutput) EndFunc but return me only top header criptograph , and body text readable not why ?
Musashi Posted November 15, 2019 Posted November 15, 2019 1 hour ago, faustf said: why ? Are we still talking about P7M files ? In case yes, please read the text that @Nine has linked to : https://filext.com/file-extension/P7M P7M files are encrypted and you need a suitable software to read them (and of course the password). "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
faustf Posted November 15, 2019 Author Posted November 15, 2019 yea openssl i think i read a tute right now i must try ,soon if find a solution i post somthing thankz again >D
faustf Posted November 15, 2019 Author Posted November 15, 2019 finally , after test many conbination uff..... i find a openssl key . 1. instal openssl in c:\openssl 2. enter in cmd and go in bin of c:\openssll 3 run command for extract content ..... this for xml for italian Fattura Elettronica openssl smime -verify -noverify -in file.xml.p7m -inform DER -out file.xml this not work for xml, but work for pdf probably openssl smime -in documento.pdf.p7m -inform PEM -verify -CAfile CA.pem -out documento.pdf or openssl smime -verify -noverify -in documento.pdf.p7m -inform DER -out documento.pdf now i try to automate by autoit ..... saty tuned thankz at all for support
faustf Posted November 15, 2019 Author Posted November 15, 2019 little bit questions i set openssl path in ambient variable , if i open cmd , in anyelse position and call openssl work , but if i run it by autoit return me 'openssl' is not recognized as an internal or external command, operable program or batch file. how is possible ?? Func _OpenSSL_Conv($path) ; syntax for convert => "openssl smime -verify -noverify -in file.xml.p7m -inform DER -out file.xml " Local $sLPathXMLNew=StringTrimRight($path,"4") ConsoleWrite ('openssl smime -verify -noverify -in ' & $path & ' -inform DER -out '&$sLPathXMLNew &@CRLF) Local $iPID = Run(@ComSpec & " /c " & 'openssl smime -verify -noverify -in ' & $path & ' -inform DER -out '&$sLPathXMLNew, "", @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD) ;Sleep(1000) ;ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : StdoutRead($iPID) = ' & StdoutRead($iPID) & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console ;Sleep(1000) ;StdinWrite($iPID, "list disk" & @CRLF) ;StdinWrite($iPID, "Exit" & @CRLF) ProcessWaitClose($iPID) ;Sleep(1000) ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead. ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : StdoutRead($iPID) = ' & StdoutRead($iPID) & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console ProcessWaitClose($iPID) Local $sOutput = StdoutRead($iPID) ConsoleWrite($sOutput) EndFunc ;==>_CMD_Type
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now