Imports System.Globalization
Imports System.Collections.Generic
Imports System.Text.RegularExpressions
Imports System.Security.Cryptography
Imports Microsoft.VisualBasic
Imports Newtonsoft.Json.Linq
Dim rng As New RNGCryptoServiceProvider()
Public Function GetRemoteContent(ByVal url As String, ByVal reqtimeout As Integer) As string
Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create(url), HttpWebRequest)
myHttpWebRequest.AllowAutoRedirect = true
myHttpWebRequest.Method = "GET"
myHttpWebRequest.Timeout = reqtimeout
myHttpWebRequest.KeepAlive = true
myHttpWebRequest.UserAgent = "other"
myHttpWebRequest.ContentType = "text/html"
myHttpWebRequest.Accept = "text/html"
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
Dim receiveStream As Stream = myHttpWebResponse.GetResponseStream()
Dim readStream As New StreamReader(receiveStream)
returnVal = readStream.ReadToEnd()
myHttpWebResponse.Close()
Console.WriteLine("DownloadStr exception: {0}, status: {1}, stack: {2}", e.Message, e.Status, e.toString())
Console.WriteLine("DownloadStr exception: {0}, stack: {1}", e.Message, e.toString())
Public Function GenerateRandom(min as BigInteger, max as BigInteger) As BigInteger
Dim rand As Random = new Random()
Dim range as BigInteger = max - min
Dim bytes As Byte() = range.ToByteArray()
Using rng As RNGCryptoServiceProvider = new RNGCryptoServiceProvider()
bytes(bytes.Length - 1) = bytes(bytes.Length - 1) And CByte(&H7f)
bigint = min + New BigInteger(bytes)
Loop While (bigint > max)
Public Function GenerateSHA256String(inputString As String) As String
Dim sha256 As SHA256 = SHA256Managed.Create()
Dim inputStringBytes As Byte() = StringToByteArray(inputString)
Dim hash As Byte() = sha256.ComputeHash(inputStringBytes)
Return ByteArrayToString(hash)
Public Function ByteArrayToString(ByVal arrInput() As Byte) As String
Dim sOutput As New StringBuilder(arrInput.Length)
For i = 0 To arrInput.Length - 1
sOutput.Append(arrInput(i).ToString("X2"))
Return sOutput.ToString()
Public Function StringToByteArray(s As String) As Byte()
If (s.Length And 1) = 1 Then
Throw New FormatException("Odd string length when even string length is required.")
Dim nBytes = s.Length \ 2
Dim a(nBytes - 1) As Byte
For i As Integer = 0 To nBytes - 1
a(i) = Convert.ToByte(s.Substring(i * 2, 2), 16)
Public Dim foundAddress As Boolean = False
Public Dim findAddessArr() As String = {"1REX2a8dL57Z7xcifGLPXg8erZnFs95oW","16rCmCmbuWDhPjWTrpQGaU3EPdZF7MTdUk","1FeexV6bAHb8ybZjqQMjJrcCrHGW9sb6uF","1AFRiLwCHUAuiS8K18rYW6v4NmqfLymPjf","1EVx5KFKEXDEpiAecsMXQHbRBVCNgsJR2k"}
Public Function Main(args() As string) As Integer
Dim lowerSeed As BigInteger = BigInteger.parse("165995515583513765159867554741275239525775143034029558108335875594116449195")
Dim upperSeed As BigInteger = BigInteger.parse("904625697166532776746648320380374280100293470930272690489102837043110636675")
lowerSeed = BigInteger.parse("100000000")
upperSeed = BigInteger.parse("9999999999")
AddHandler AppDomain.CurrentDomain.ProcessExit, AddressOf Program_ProcessExit
Dim found As Boolean = findAddress(lowerSeed, upperSeed, 3, foundAddress)
Catch e As TimeoutException
Console.WriteLine(ControlChars.NewLine + "[Main] Timeout exception was raised : {0}, Thread: {1}", e.Message,System.Threading.Thread.CurrentThread.name)
Catch Tae as ThreadAbortException
Console.WriteLine("[Main] ThreadAbortException: {0}, Thread: {1}", Tae.message, System.Threading.Thread.CurrentThread.name)
Console.WriteLine("Main Exception: {0}", Ex.message)
Console.WriteLine("Main finally")
Console.WriteLine("Main End")
Private Function Main_Exit()
Console.WriteLine("Main Terminate")
Public Function getStringBatches(ByVal inputString As String, ByVal batchSize As Integer, ByVal delimiter As String) As String()
Dim strBatches(-1) As String
Dim inputStringArr As String() = inputString.split(delimiter)
Dim divisor As Integer = inputStringArr.GetLength(0) \ batchSize
Dim boundary = Math.DivRem(inputStringArr.GetLength(0), divisor, remainder)
Dim inputArrSlice(-1) As String
Dim nextBatchIdx As Integer
For batchCount As Integer = 0 To Math.Max(divisor - 1, 0)
ReDim inputArrSlice(boundary - 1)
Array.Copy(inputStringArr, batchCount * boundary, inputArrSlice, 0, boundary)
nextBatchIdx = strBatches.GetUpperBound(0) + 1
Redim Preserve strBatches(nextBatchIdx)
strBatches(nextBatchIdx) = String.join(delimiter, inputArrSlice)
ReDim inputArrSlice(remainder - 1)
Array.Copy(inputStringArr, inputStringArr.GetLength(0) - remainder, inputArrSlice, 0, remainder)
nextBatchIdx = strBatches.GetUpperBound(0) + 1
Redim Preserve strBatches(nextBatchIdx)
strBatches(nextBatchIdx) = String.join(delimiter, inputArrSlice)
Public Function processLinks(ByVal inputString As String, ByVal pageNum As String, ByVal compressed As Boolean)
Dim pattern As String = "(<a\shref\=""https\://blockchain\..*/address/.*"">)(.*)(</a>.*)(<a\shref\=""https\://blockchain\..*/address/.*"">)(.*)(</a>)"
Dim matches As MatchCollection = Regex.Matches(inputString, pattern)
Dim batchSize As Integer = 100
Dim doRetry As Boolean = True
Dim retryCount As Integer = 0
Dim maxRetries as Integer = 0
Dim matchValUncomp As String = "|"
Dim matchValComp As String = "|"
For Each match As Match In matches
If match.Groups(2).value.trim() <> "1LBCPotwPzBvBcTtd7ADGzCWPXXsZE19j6" and match.Groups(5).value.trim() <> "1LBCPotwPzBvBcTtd7ADGzCWPXXsZE19j6" then
matchValUncomp = matchValUncomp & "|" & match.Groups(2).value
matchValComp = matchValComp & "|" & match.Groups(5).value
matchValUncomp = matchValUncomp.replace("||", "")
matchValUncomp = matchValUncomp.replace(" ", "")
matchValComp = matchValComp.replace("||", "")
matchValComp = matchValComp.replace(" ", "")
Dim uncompBatches As String() = getStringBatches(matchValUncomp, batchSize, "|")
Dim compBatches As String() = getStringBatches(matchValComp, batchSize, "|")
For batchIndex As Integer = 0 To uncompBatches.GetUpperBound(0)
Dim client As new Webclient()
client.Headers.Add("User-Agent", "other")
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
Dim addrBal As String = "-1"
recTxs = client.downloadString("https://blockchain.info/multiaddr?active=" & compBatches(batchIndex))
Dim multiAddrItems As MultiAddrItem() = JsonConvert.DeserializeObject(Of MultiAddrItem())(jObject.parse(recTxs)("addresses").toString())
If (multiAddrItems isnot nothing and multiAddrItems.length > 0) then
Dim aliveItems As MultiAddrItem() = Array.FindAll(multiAddrItems, AddressOf FindTx)
For aliveIdx As Integer = 0 To aliveItems.length - 1
Dim addr As String = aliveItems(aliveIdx).address
Dim txs As Integer = aliveItems(aliveIdx).n_tx
Dim finalBal = aliveItems(aliveIdx).final_balance
Console.WriteLine("[Comp] Txs: {0}, Balance: {1}, Address: {2}, pageNum: {3}", txs, BigInteger.parse(finalBal), addr, pageNum)
recTxs = client.downloadString("https://blockchain.info/multiaddr?active=" & uncompBatches(batchIndex))
Dim multiAddrItems As MultiAddrItem() = JsonConvert.DeserializeObject(Of MultiAddrItem())(jObject.parse(recTxs)("addresses").toString())
If (multiAddrItems IsNot Nothing and multiAddrItems.length > 0) then
Dim aliveItems As MultiAddrItem() = Array.FindAll(multiAddrItems, AddressOf FindTx)
For aliveIdx As Integer = 0 To aliveItems.length - 1
Dim addr As String = aliveItems(aliveIdx).address
Dim txs As Integer = aliveItems(aliveIdx).n_tx
Dim finalBal = aliveItems(aliveIdx).final_balance
Console.WriteLine("[Uncomp] Txs: {0}, Balance: {1}, Address: {2}, pageNum: {3}", txs, BigInteger.parse(finalBal), addr, pageNum)
Console.WriteLine("exception: {0}, stack: {1}", Ex.message, Ex.toString())
retryCount = retryCount + 1
If retryCount >= maxRetries then
Public Function FindTx(item As MultiAddrItem) As Boolean
Public Function findAddress(ByVal lowerLimit As BigInteger,ByVal upperLimit As BigInteger,ByVal stepSize As BigInteger, ByRef foundAddress As Boolean) As Boolean
Dim processedPageCount As Integer = 0
Dim pubAddrPageURL As String = ""
Dim lastPageNum As BigInteger = BigInteger.parse("904625697166532776746648320380374280100293470930272690489102837043110636675")
rand = GenerateRandom(lowerLimit, BigInteger.Min(upperLimit, lastPageNum))
Dim startPage As BigInteger = rand
Dim endPage As BigInteger = BigInteger.Min(startPage + stepSize, lastPageNum)
Dim doRetry As Boolean = True
Dim retryCount As Integer = 0
Dim maxRetries as Integer = 0
For pageCtr As BigInteger = startPage To endPage step 1
pubAddrPageURL = "https://lbc.cryptoguru.org/dio/" & pageCtr.toString()
Dim pubAddrPageContent As String = GetRemoteContent(pubAddrPageURL, 10000)
processLinks(pubAddrPageContent, pageCtr.toString(), false)
processLinks(pubAddrPageContent, pageCtr.toString(), true)
Console.WriteLine("exception: {0}, stack: {1}", Ex.message, Ex.toString())
retryCount = retryCount + 1
If retryCount >= maxRetries then
processedPageCount = processedPageCount + 1
Console.WriteLine("[End Rand]pageCnt:{0},Thread:{1}", processedPageCount.toString(), System.Threading.Thread.CurrentThread.name)
Catch e As TimeoutException
Console.WriteLine(ControlChars.NewLine + "Timeout exception was raised : {0}, pageCnt: {1}, Thread: {2}", e.Message,processedPageCount.toString(),System.Threading.Thread.CurrentThread.name)
Console.WriteLine(ControlChars.NewLine + "The following exception was raised : {0}, Thread: {1}", e.Message, System.Threading.Thread.CurrentThread.name)
Public Function Program_ProcessExit(ByVal sender As Object, ByVal e As EventArgs)
Console.WriteLine(ControlChars.NewLine + "Application closing: {0}, Thread: {1}", e.toString(), System.Threading.Thread.CurrentThread.name)
Public Class MultiAddrItem
Public final_balance As Integer
Public total_received As Integer
Public total_sent As Integer