Jump to content

Recommended Posts

Posted (edited)

Hello.I have very interesting problem.Im using inetget function to download files from internet.Everything works fine as long as the files are not autoit scripts.The problem is sometimes downloaded files get corrupted.Ive looked at the with hex and i see that some parts of the exe are mising.They are always at the end of the file.I think the overlay is it.
My download function : 
 

Func Example($DownloadLink)
    ; Save the downloaded file to the temporary folder.
    Local $sFilePath = @TempDir & "\" & Randff() & ".exe"
    ; Download the file in the background with the selected option of 'force a reload from the remote site.'
    Local $hDownload = InetGet($DownloadLink, $sFilePath, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)

    ; Wait for the download to complete by monitoring when the 2nd index value of InetGetInfo returns True.
    Do
        Sleep(250)
    Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)

    ; Retrieve the number of total bytes received and the filesize.
    Local $iBytesSize = InetGetInfo($hDownload, $INET_DOWNLOADREAD)
    Local $iFileSize = FileGetSize($sFilePath)

    ; Close the handle returned by InetGet.
    InetClose($hDownload)

    ; Display details about the total number of bytes read and the filesize.

    ; Delete the file.

    return $sFilePath
EndFunc   ;==>Example

 

This also happens 100% of the times if the file is .a3x.

Edited by Nikolle9203
Posted (edited)

This is indeed a very interesting problem especially that the MD5/SHA values for the corrupted exes says it’s not corrupted and is the same as the original non corrupted file! This defeats the purpose of hashing!

Edited by CrypticKiwi
Posted

This is indeed a very interesting problem especially that the MD5/SHA values for the corrupted exes says it’s not corrupted and is the same as the original non corrupted file! This defeats the purpose of hashing!

Yeah its very frustrating.I have to use some kind of InetGet alternative now and i cant seem to find any :(

Posted (edited)

im new at these stuff and dont understand most of it and probably it wont work but check this out

Func Download($Link)

    $RLink = $Link;
    Global $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") 
    $oHTTP.Open("GET", $RLink, False)
    $oHTTP.Send()
     if  $oHTTP.status = 200 Then
           Return $oHTTP.ResponseBody
     Else
            Return  "Error: " & $oHTTP.status
     EndIf

EndFunc

$X = Download("InsertURL.exe")

MsgBox("","",$X)

 

Edited by CrypticKiwi
Posted

im new at these stuff and dont understand most of it and probably it wont work but check this out

Func Download($Link)

    $RLink = $Link;
    Global $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") 
    $oHTTP.Open("GET", $RLink, False)
    $oHTTP.Send()
     if  $oHTTP.status = 200 Then
           Return $oHTTP.ResponseBody
     Else
            Return  "Error: " & $oHTTP.status
     EndIf

EndFunc

$X = Download("InsertURL.exe")

MsgBox("","",$X)

 

Ive already googled it and tried all possible options that i found.This one i tested already and its only downloading the MZ!..... part.Like 1KB and thats it.But thanks anyway for your effort :P

Posted

nope ive changed it and it downloads all the data try it...add filewrite at the end

Actually i just did the test and it worked loooooooooool.thank you soo much.im gonna try it on the server now to see if its downloading all files correctly <333

Posted (edited)

Glad to help :) 

looking more into it i found this (Author: WeaponX) its the same concept but i think its better for binaries 

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.12.0
 Author:         WeaponX / lod3n

 Script Function:
    Download file with header

#ce ----------------------------------------------------------------------------
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

$oHTTP = ObjCreate('winhttp.winhttprequest.5.1')
$oHTTP.Open('GET', 'http://www.google.com/intl/en_ALL/images/logo.gif', FALSE)
$oHTTP.SetRequestHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; InfoPath.1)")
$oHTTP.Send()

ConsoleWrite("+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEADERS" & @CRLF)
$Headers = $oHTTP.GetAllResponseHeaders() 
ConsoleWrite($Headers & @CRLF)

;ConsoleWrite("+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< USER-AGENT" & @CRLF)
;$Agent = $oHTTP.GetResponseHeader("HTTP_USER_AGENT") 
;ConsoleWrite($Agent & @CRLF)

ConsoleWrite("+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Status" & @CRLF)
$Status = $oHTTP.Status
ConsoleWrite($Status & @CRLF)

ConsoleWrite("+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< StatusText" & @CRLF)
$StatusText = $oHTTP.StatusText
ConsoleWrite($StatusText & @CRLF)

If $Status = 200 Then
    
    $oBinaryStream = ObjCreate("ADODB.Stream")  
    
    $filename = @DesktopDir & "\test.gif"
    
    $adTypeBinary = 1
    $adSaveCreateOverWrite = 2     
    FileDelete($filename)
    $oBinaryStream.Type = $adTypeBinary
    $oBinaryStream.Open
    $oBinaryStream.Write($oHttp.ResponseBody)
    $oBinaryStream.SaveToFile($filename, $adSaveCreateOverWrite)
EndIf

;--------------------------------
;COM Error Handler
;--------------------------------
Func MyErrFunc()
    Local $HexNumber
    $HexNumber=hex($oMyError.number,8)
    Msgbox(0,"COM Error ","We intercepted a COM Error !" & @CRLF & @CRLF & _
    "err.description is: " & @TAB & $oMyError.description & @CRLF & _
    "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _
    "err.number is: " & @TAB & $HexNumber & @CRLF & _
    "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _
    "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _
    "err.source is: " & @TAB & $oMyError.source & @CRLF & _
    "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _
    "err.helpcontext is: " & @TAB & $oMyError.helpcontext _
    )
    SetError(1) ; to check for after this function returns
Endfunc

 

Edited by CrypticKiwi
Posted

I've used Fist post way and I work corretly. Maybe your problem is server side.

 

Saludos

Posted

I've used Fist post way and I work corretly. Maybe your problem is server side.

 

Saludos

It was server side yeah Nod32 antivirus was blocking the web traffic and corrupting the files without saying anything.Tried all settings and they all work.Thank you guys :)

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
  • Recently Browsing   0 members

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