Jump to content

[Solved] decompressing Gzip`ped binary string


Recommended Posts

I wanted to decompress Gzip data so I found this topic, where a guy recommened to do this with this UDF: hire & tried to rewrite it a little.

DLL is hire: http://www.zlib.net/zlib123-dll.zip

it gets Source from webpage that is in gzip format, converts it to binary, gets binary lenght & then tries to decompress this binary string.

First try is hir: it Results in -3 I have no clue what does it mean: Im I on a right track hire ?

#include <INet.au3>
#include "zlib_udf.au3"

  _Zlib_Startup()
  $bin=_INetGetSource('http://g.e-hentai.org/non-h')
  $bin= StringToBinary($bin,4) ;4=binary is maybe utf
  $binlen=BinaryLen($bin)
  
  $uncompressed=_Zlib_UncompressBinary($bin,$binlen)
  
  ConsoleWrite($uncompressed & @CRLF & @CRLF)  
  
  _Zlib_Shutdown()
Edited by goldenix
My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
Share on other sites

Okey I found the solution. You wont like it. Nor do I. But its better than the alternative with gzip.exe & annoying CMD console window popping out.

Basically you will just shellecsecutewait("WindowsApplication1.exe")

Its Visual basic solution:

You can also Grab the exe file hire! or make it yourself, see code below: [Note that it will decompress Temp_HTMLSource.gz file in your @scriptdir & save it as Temp_HTMLSource.gz.html, it wont delete original file.]

To make executeble yourself:

Install Visual basic 2008 express, create new project[CRTL+N], choose Form Application. Press F7 or View->Code, paste & replace everything with this code & press Build->WindowsApplication.

Executable file will be created in:

C:\Documents and Settings\YOUR USERNAME\Local Settings\Application Data\Temporary Projects\WindowsApplication1\bin\Release

Imports System
Imports System.Collections.Generic
Imports System.IO
Imports System.IO.Compression

Public Class CompressionSnippet

    Private Sub CompressionSnippet_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Hide()
        UncompressFile("Temp_HTMLSource.gz") ' Name of the compressed file
        Me.Close()
    End Sub

    Public Shared Sub UncompressFile(ByVal path As String)
        Dim sourceFile As FileStream = File.OpenRead(path)
        Dim destinationFile As FileStream = File.Create(path + ".html") ' Outputs test.gz.txt

        ' Because the uncompressed size of the file is unknown, 
        ' we are imports an arbitrary buffer size.
        Dim buffer(4096*10000) As Byte
        Dim n As Integer

        Using input As New GZipStream(sourceFile, _
          CompressionMode.Decompress, False)

            n = input.Read(buffer, 0, buffer.Length)
            Do While n <> 0
                destinationFile.Write(buffer, 0, n)
                n = input.Read(buffer, 0, buffer.Length)
            Loop

        End Using

        ' Close the files.
        sourceFile.Close()
        destinationFile.Close()
    End Sub
End Class
Edited by goldenix
My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...