rootx Posted August 3, 2020 Share Posted August 3, 2020 (edited) how can I extract all the png images contained in a file? I would like to save each range in a .png file, as I do with the hex editor manually. start = 89 50 4E 47 0D 0A 1A 0A End = 49 45 4E 44 AE 42 60 82 Thx Edited August 6, 2020 by rootx Link to comment Share on other sites More sharing options...
TheXman Posted August 3, 2020 Share Posted August 3, 2020 (edited) It depends on where and how the images are stored in the executable. If the images are store in the executable's resource area, then you could use functions in the WinAPIRes UDF file to access them. If they are stored somewhere else in the executable, then you would need some other method(s). If they are stored compressed or encoded, then you need to take that into consideration also. In other words, who knows because you haven't provided enough information. Edit: I just recognized that you specifically said a .bin file, not an executable. Not sure what your .bin file is and how it was created, other than it's a binary file. Assuming that the images are not stored compressed or encoded in the .bin file, you could open file the file as binary and extract file the binary image data using the starting and ending tags, with a regular expression. You could then save that extracted binary data as a binary file. Edit: Actually a StringRegexp function probably wouldn't work because it would stop when a null byte (0x00) was encountered. Since you are familiar with extracting the .png files with your hex editor, maybe you can automate using it to extract the files. Or, you could open and read through the binary file byte by byte looking for your starting and ending tags. Edited August 3, 2020 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
TheDcoder Posted August 3, 2020 Share Posted August 3, 2020 @rootx You have to go through each byte and compare the values with known values. Remember that a byte is just nothing but an 8 digit binary number My apologies for the lack of an example, I am a bit busy at the moment. Hopefully someone will take out the time to show you rootx 1 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
jchd Posted August 3, 2020 Share Posted August 3, 2020 (edited) Yo can use the code provided in this thread to perform regex search in binary: Edited August 3, 2020 by jchd This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
TheXman Posted August 3, 2020 Share Posted August 3, 2020 1 minute ago, jchd said: Yo can use the code provided in this thread to perform regex search in binary: Since StringRegexp is a function that returns strings, would the result, if it had embedded null bytes (0x00), be the whole result or would it be truncated at the first null byte? CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
jchd Posted August 3, 2020 Share Posted August 3, 2020 (edited) It will work. The binary is converted to a string of UCS2 encoding units with exact same data: only the encoding is changed. PCRE (the underlying regex processing code is imune to embedded NULLs. In AutoIt 0x00 is only a string termination on I/O (AFAICT). Edited August 3, 2020 by jchd TheXman 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
rootx Posted August 5, 2020 Author Share Posted August 5, 2020 On 8/3/2020 at 10:01 PM, TheDcoder said: @rootx You have to go through each byte and compare the values with known values. Remember that a byte is just nothing but an 8 digit binary number My apologies for the lack of an example, I am a bit busy at the moment. Hopefully someone will take out the time to show you Thanks for the tip, I found my solution, FileSetPos and then loop the entire file. TheDcoder 1 Link to comment Share on other sites More sharing options...
TheDcoder Posted August 5, 2020 Share Posted August 5, 2020 @rootx Glad to be of assistance EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Nine Posted August 5, 2020 Share Posted August 5, 2020 (edited) @rootx Could you provide your code, someone else could find it helpful. Thanks. Edited August 5, 2020 by Nine “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) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
rootx Posted August 6, 2020 Author Share Posted August 6, 2020 (edited) 13 hours ago, Nine said: @rootx Could you provide your code, someone else could find it helpful. Thanks. I read this discussion as jchd advised me. Edited August 6, 2020 by rootx Link to comment Share on other sites More sharing options...
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