Sign in to follow this  
Followers 0
Decipher

Binary to readable ASCII text format?

6 posts in this topic

#1 ·  Posted (edited)

Peers: (binary model), the peers value may be a string consisting of multiples of 6 bytes. First 4 bytes are the IP address and last 2 bytes are the port number. All in network (big endian) notation. The list of peers is length 50 by default. How can I convert the attached?

http://en.wikipedia.org/wiki/Endianness#Big-endian

I've tried BinaryToString with no luck. Thanks in advance.

Peers.txt

Edited by Decipher

Spoiler

censored.jpg

 

Share this post


Link to post
Share on other sites



Lookup DllStructCreate in help. Read carefully and come back if you don't succeed.


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 here
RegExp tutorial: enough to get started
PCRE 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)

Share this post


Link to post
Share on other sites

Would you please give me an example. I read the documentation for the DllStructCreate function but its confusing to me on how I can use it to change this: uïiƒ¡ã into 127.0.0.1:80

What type would I be using, etc.


Spoiler

censored.jpg

 

Share this post


Link to post
Share on other sites

you could create a struct with "char"´s with the lenght of your "text" and fill the struct with the text

create a struct with "bytes" at the same position

then read these "bytes" one by one and you get the conversion....

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

What type would I specify because I don't think its integers?

So I read the bytes one by one and the read information is ASCII?

I'm still completely lost as to how this actually works.

I've tried:

$a = DllStructCreate(FileRead(@DesktopDir & "Peers.txt"))
For $i = 1 To 10
MsgBox(0,"",DllStructGetData($a, $i))
Next

Dosen't work. Is it possible that the character's ASCII code is what I'm after? I could code that but I wouldn't have a way to verify that it is correct.

Edited by Decipher

Spoiler

censored.jpg

 

Share this post


Link to post
Share on other sites

.


Spoiler

censored.jpg

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • wakillon
      By wakillon
      BinaryToAu3Kompressor v1.0.5.4
       

       
      It's now possible to see the best compression ratio using LZMA, LZNT and Base64 compressions with differents combinations.
      Nothing too complicate, you drag'n drop a file on the picture and script Test all compression types and return the ratios.
      ( Test duration depends of file size, slowest compression is LZNT, but all decompressions are fast  )
      Free to you after, to choose the compression(s) you want...
      Yes, LZMA needs a dll ( embedded & compressed in script ) but brings a powerfull compression. 
      It opens scite with your file compressed to an au3 script with or without decompression function as you want.
      Hold Left Shift key when clicking button for just copy script to clipboard.
      Use the 3 compressions at a time works but doesn't give a good ratio, that's why i don't display it.
      Usefull for little files you want include in your scripts !
      No externals files needed, they are already in script.
      Previous downloads : 1103
      Source and Executable
      BinaryToAu3Kompressor will be added to the next version of >SciTEHopper
      Thanks to Ward for his >Base64.au3 and LZMA.au3, and trancexx for his >LZNT functions and his >Base64Decode function.
    • fopetesl
      By fopetesl
      Need to read a small file which looks like
      01 01 01 00 21 21 48 4F ����!HHO (cut from hexedit) First four are binary but don't show, last four are ascii "!HHO"
      I have tried to split the file and look for the ascii string but not succeeded:
      ; Set the working directory ... or set PATH! ... FileChangeDir("C:\S3_GUI\ncat\") ; Run(@ComSpec & " /k " & "C:\S3_GUI\ncat\Home.bat", "", @SW_HIDE);;comment: not over write Local $hFileOpen = FileOpen("C:\S3_GUI\ncat\homerep", $FO_READ) ;; homerep Local $sFileRead = FileRead($hFileOpen) Local $Comp = StringInStr ($sFileRead,"!HHO",1,4) If( $Comp = 1) Then MsgBox($MB_OK, "Head is Home", "!HHO") Else MsgBox($MB_OK, "Head not Home!","!HHx") EndIf Fails every time.
      If I open it as binary then I lose the ascii?
      I've been advised to include the whole file but it's getting big. You need to see it all?
    • TheSaint
      By TheSaint
      I had a need, and so I developed.
      Before I did that though, I did a quick search of the forum, and found a few things, but none seemed to suit what I really wanted ... though to be honest, I did not investigate them deeply or search extensively. In any case, I am not very good at modifying the code of others, nor do I enjoy doing so, so in the end I decided it was best to start from scratch ... re-inventing the wheel perhaps, but a wheel I feel a certain degree of comfort with. I also thought about Maps, but don't know enough.
      _IniString Functions (was Ini_InMem)
      Ini in memory
      Settings INI - Read/Write once to the disk
      INI File Processing Functions
      ... sure to be others.
      As with all my stuff, feel free to use (no guarantees) or modify ... just give me credit where due.
      I always go for the quick & simple approach, as those who know me here, are well aware, so without a doubt, my code could be improved - sped up, RegExp used, etc. So feel free to do that, and convert into a proper UDF, if you want, following best practices etc, as I am sure others will appreciate it.
      Recently, I have come upon a need to extract data from an approximately 50 Mb downloaded Index file, just extracting the few elements I need, and storing them in an INI file. It is quite a time consuming process, especially on my underpowered Netbook, which is where I am using the program I built. I have been considering ways to speed up things. Two good sounding methods, out of several possibles, have come to mind - 1) RAM Disk and 2) Virtual INI processing. That last being a better option, when sharing code (program) with others.
      Another method, which I am currently using, that did give me some measurable benefit, was to download the almost 50 Mb Index file in Stages (i.e. 30 x 1.4 Mb roughly), extracting data from each in turn. I have also considered extracting to 10 (or 11) separate INI files, rather than the single large INI file (4~5 Mb), as things noticeably slow up as the INI file increases in size ... obviously due to writing time.
      I can't really speed up the extraction process, but that last method may speed up the writing stage.  However, it would require significant program changes, and perhaps not gain me much benefit. To complicate things, there are too many Section names (Index ID's) for the IniReadSectionNames command, so I have had to split them off into their own (read/write) line-by-line index file, and create code to deal with duplicates. When read, Index ID's and Titles populate a Listbox control in a user GUI.
      So at this point in time, it seems best to use the Virtual INI approach to gain a significant reduction in time taken. For my own specific use, with my slow Netbook, I may also use a RAM Disk.
      Due to the aforementioned INI issues, and lack of available specific data, probably because it is always  program concentric, I have created an ASCII Checker program, which I guess you can say, is AutoIt  concentric. Because others may also find it handy, I am providing it here. NOTE - As yet, I am only aware that Escape characters exist, but have not investigated or catered for them in any way.
      ASCII Checker.zip

      The Virtual_INI_UDF is still a work in progress, though I have done most of the functions now, with the working but incomplete _Ini_Test function, still requiring changes etc from the information gleaned by the ASCII Checker program.
      Here's something to play with meanwhile.
      Updated files (24th February 2017)
      Virtual_INI_UDF.au3  NEW
      Example.au3 (23rd February 2017)
      All pretty basic, but managed to load my 4 Mb INI file (seemingly ok, but took a few seconds) ... though I have only worked with much smaller testing ones so far.
      P.S. While I have done a fair amount of testing, it has been pretty basic, and mostly limited to the examples provided. Testing has definitely not been extensive.
       
    • WoodGrain
      By WoodGrain
      Hi All,
      Trying to convert a number to binary zeros and ones but I'm getting a result I don't understand and looks more like hex than binary.
      Here's my basic code:
      $myNum = 11 $myNumBin = Binary($myNum) MsgBox(0, "Binary result", $myNumBin) What I want is "1011", what I get is 0x0B000000.
      Thanks!
    • theak
      By theak
      Trying to find a quick way to convert 30k+ WordPerfect files into Word.
      Will probably run it locally from an admin machine or server so user permissions won't affect it.
      My idea was just to open the file, select all, copy, open new word doc, paste, file, save....
      What would be the best way to go about scripting something in this way?