.Celtics (08-21-2010),aLcohoL_95 (08-21-2010),b7bassam (07-25-2015),House (09-28-2010),Lolland (08-21-2010),matthieu503 (05-04-2012),mnpeepno2 (08-21-2010),NextGen1 (08-21-2010),skiiiz (08-21-2010),Terell. (08-21-2010),Tony Stark` (02-09-2011)
Note: Downloaders are restricted on MPGH. Therefore, don't use them in the programs you release!
I decided to release a small opensource project for a proper downloader.
The whole project is included.
[PHP]'This code is fully self-written.
'(c) Blubb1337
'Enjoy
Imports System.IO
Imports System.Text
Imports System.Net
'Since a lot of people seem to need a proper downloader, I decided 2 release a PROPER updater
'Most updater use my.network.downloadfile, however this does not show progress and it generally sucks!
'This updater uses a webclient. Using a webclient, you can display the current progress, the received bytes
'and the total bytes to receive.
'You also have a download completed event.
'How to use this?
'This is really easy, the only thing you need to change -> 4 Variables
'links
'Private Const _version As String = "http:/version.txt"
'Private Const _FileToDL As String = "http:/Recorder.exe"
'Private Const _log As String = "https://changelog.txt"
'name
'Private Const _Name As String = "Recorder"
'I think this is pretty self-explanatory. You sure don't need to have a log, you can just take it out.
'Furthermore, this updater uses multithread to check the newest version/load the checklog.
'Usually the program executes one sub/function/action after another. With multithreads you can run
'different subs/functions or whatever at the same time!
'You may also change the prioritys of the multithreads
'If you want to unpack a file after it has been downloaded, you can go for the sharpziplibrary:
'https://www.mpgh.net/forum/33-visual-basics/126996-tutorial-unzipping-vb-net.html
'Sub ExtractZip(ByVal FileToUnzip As String, ByVal WhereToSave As String, Optional ByVal Password As String = "")
'Dim fz As New FastZip
' fz.Password = Password
' fz.ExtractZip(FileToUnzip, WhereToSave, "")
' End Sub
Public Class Form1
#Region "Declarations"
'new webclient to for downloading
WithEvents webC As New Net.WebClient
Private apppath As String = Application.StartupPath & "\"
Private filename As String
'avoid the same filename twice
Private i As Integer = 1
'received/total bytes
Private total, current As Integer
'links
Private Const _version As String = "https://version.txt"
Private Const _FileToDL As String = "https://Recorder.exe"
Private Const _log As String = "https://changelog.txt"
'name
Private Const _Name As String = "Recorder"
'get a pages source code
Private Function loadPage(ByVal page As String)
Dim req As WebRequest = WebRequest.Create(page)
Dim resp As WebResponse = req.GetResponse()
Dim s As Stream = resp.GetResponseStream()
Dim sr As StreamReader = New StreamReader(s, Encoding.ASCII)
Dim doc As String = sr.ReadToEnd()
Return doc
End Function
#End Region
#Region "Download/Progress"
Private Sub cmdDownload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDownload.Click
If cmdDownload.Text = "Download" Then
'start backgroundworker
bgwDownload.RunWorkerAsync()
Else
'start the program
Process.Start(filename)
'end this application
Application.Exit()
End If
End Sub
Private Sub webC_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles webC.DownloadFileCompleted
' MsgBox("Download complete." & vbNewLine & vbNewLine _
' & "Saved at: " & filename)
cmdDownload.Text = "Start " & _Name
cmdDownload.Enabled = True
End Sub
Private Sub webC_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles webC.DownloadProgressChanged
current = e.BytesReceived 'bytes it dled already
total = e.TotalBytesToReceive 'total bytes it has to dl
If total <> current Then 'if they are not the same
cmdDownload.Enabled = False
End If
pbProgress.Value = e.ProgressPercentage 'show the procent percentage
'pbProgress.Text = CInt(current / 1024) & "/" & CInt(total / 1024) & " KB received | " & e.ProgressPercentage & " %"
lblprogress.Text = CInt(current / 1024) & "/" & CInt(total / 1024) & " KB received | " & e.ProgressPercentage & " %"
End Sub
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles bgwDownload.DoWork
'start downloading the file
webC.DownloadFileAsync(New Uri(_FileToDL), filename)
End Sub
#End Region
#Region "Startup"
Private Sub UpdateApp_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'to avoid threadovertaking actions -> program would just end
Control.CheckForIllegalCrossThreadCalls = False
'multithread so multiple things can be done at the same time -> load changelog
Dim cl As New Threading.Thread(AddressOf changelog)
cl.Priority = Threading.ThreadPriority.Highest
cl.Start()
'show the current version of the application
lblCurV.Text &= Application.ProductVersion
'to not replace the old version
Do While IO.File.Exists(apppath & _Name & "_Updated - " & i & ".exe")
i += 1
Loop
filename = apppath & _Name & "_Updated - " & i & ".exe"
End Sub
Private Sub changelog()
txtChangeLog.Text = loadPage(_log)
End Sub
Private Sub newversion()
lblNewV.Text &= loadPage(_version)
End Sub
Private Sub UpdateApp_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
Dim checkv As New Threading.Thread(AddressOf newversion)
checkv.Priority = Threading.ThreadPriority.Highest
checkv.Start()
End Sub
#End Region
End Class
[/PHP]
Virus Scans:
Updater for MPGH.rar - Jotti's malware scan
VirusTotal - Free Online Virus, Malware and URL Scanner
Have fun copy & pasters!
.Celtics (08-21-2010),aLcohoL_95 (08-21-2010),b7bassam (07-25-2015),House (09-28-2010),Lolland (08-21-2010),matthieu503 (05-04-2012),mnpeepno2 (08-21-2010),NextGen1 (08-21-2010),skiiiz (08-21-2010),Terell. (08-21-2010),Tony Stark` (02-09-2011)
gj
thanx for sharing it with us
CANNIBAL CORPSE P0WNS
Thanks I may use this in the future
Warrock Minion 8-13-2011 - N/AA.V.A Minion since 11-1-11 - 11-12-11
Looks good, keep it up
Good Job. Keep it up..!
Looks good , Thanks
3l3menter (08-22-2010),banned1111 (08-25-2010),Vectorzz™ (08-22-2010)
Blubb1337 (08-21-2010)
Added to tuts
Great job Kevin.
Blubb1337 (08-21-2010)
Thanks!
But I have a question,
If I have an update of the app, what should I change, the version.txt?
Last edited by .Celtics; 08-21-2010 at 10:25 AM.
About the " Private Const _FileToDL As String = "https://Recorder.exe""
Im confused there , ill give an example
For Example
I released something, so at the 1st release, what will I put there? Since I dont have the link for the updated one?
Well you could get a FTP and have a static new version.exe link and then simply delete the old one and re-upload a newer version so it has the same link. OR you could make the program read a .txt document, similar how you check the version via the internet but get the link from there.
i.e (using Blubb's loadpage function)
[php]
Private Function loadPage(ByVal page As String)
Dim req As WebRequest = WebRequest.Create(page)
Dim resp As WebResponse = req.GetResponse()
Dim s As Stream = resp.GetResponseStream()
Dim sr As StreamReader = New StreamReader(s, Encoding.ASCII)
Dim doc As String = sr.ReadToEnd()
Return doc
End Function
[/php]
Then just do
[php]
Dim LinkToDownloadFrom As String = LoadPage("https://www.yourftp.com/getlatestversionlink.txt")
[/php]
And that will tell your program where to download the latest version.
You can win the rat race,Originally Posted by Jeremy S. Anderson
But you're still nothing but a fucking RAT.
++Latest Projects++
[Open Source] Injection Library
Simple PE Cipher
FilthyHooker - Simple Hooking Class
CLR Injector - Inject .NET dlls with ease
Simple Injection - An in-depth look
MPGH's .NET SDK
eJect - Simple Injector
Basic PE Explorer (BETA)
.Celtics (08-21-2010)
Thanks! I get it naw
Very last question,
How do you make the progress bar have a text? Can find it in the properties
Sorry for being a pain-in-the-ass
Last edited by .Celtics; 08-21-2010 at 03:16 PM.