Class: Snackhack2::CryptoExtractWebsite

Inherits:
Object
  • Object
show all
Defined in:
lib/snackhack2/cryptoextractor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site, save_file: true) ⇒ CryptoExtractWebsite

Returns a new instance of CryptoExtractWebsite.



9
10
11
12
13
# File 'lib/snackhack2/cryptoextractor.rb', line 9

def initialize(site, save_file: true)
  @http = Snackhack2::get(site).body
  @site = site
  @save_file = save_file
end

Instance Attribute Details

#save_fileObject

Returns the value of attribute save_file.



7
8
9
# File 'lib/snackhack2/cryptoextractor.rb', line 7

def save_file
  @save_file
end

Instance Method Details

#bitcoinObject



36
37
38
# File 'lib/snackhack2/cryptoextractor.rb', line 36

def bitcoin
  @http.scan(/(bc(0([ac-hj-np-z02-9]{39}|[ac-hj-np-z02-9]{59})|1[ac-hj-np-z02-9]{8,87})|[13][a-km-zA-HJ-NP-Z1-9]{25,35})/)
end

#bitcoincashObject



60
61
62
# File 'lib/snackhack2/cryptoextractor.rb', line 60

def bitcoincash
  @http.scan(/[13][a-km-zA-HJ-NP-Z1-9]{33}/)
end

#dashObject



40
41
42
# File 'lib/snackhack2/cryptoextractor.rb', line 40

def dash
  @http.scan(/X[1-9A-HJ-NP-Za-km-z]{33}/)
end

#dogecoinObject



52
53
54
# File 'lib/snackhack2/cryptoextractor.rb', line 52

def dogecoin
  @http.scan(/D{1}[56789ABCDEFGHJKLMNPQRSTU]{1}[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{32}$/)
end

#ethereumObject



56
57
58
# File 'lib/snackhack2/cryptoextractor.rb', line 56

def ethereum
  @http.scan(/0x[a-fA-F0-9]{40}/)
end

#litecoinObject



48
49
50
# File 'lib/snackhack2/cryptoextractor.rb', line 48

def litecoin
  @http.scan(/[LM3][a-km-zA-HJ-NP-Z1-9]{26,33}/)
end

#moneroObject



32
33
34
# File 'lib/snackhack2/cryptoextractor.rb', line 32

def monero
  @http.scan(/[48][0-9AB][1-9A-HJ-NP-Za-km-z]{93}/)
end

#runObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/snackhack2/cryptoextractor.rb', line 15

def run
  addresses = []
  addresses << monero unless monero.nil?
  addresses << bitcoin unless bitcoin.nil?
  addresses << dash unless dash.nil?
  addresses << ethereum unless ethereum.nil?
  addresses << bitcoincash unless bitcoincash.nil?
  addresses << litecoin unless litecoin.nil?
  addresses << dogecoin unless dogecoin.nil?
  addresses << stellar unless stellar.nil?
  if @save_file
    Snackhack2::file_save(@site, "cryptoaddresses", addresses.uniq.join("\n"))
  else
    puts addresses.join("\n")
  end
end

#stellarObject



44
45
46
# File 'lib/snackhack2/cryptoextractor.rb', line 44

def stellar
  @http.scan(/G[A-Z0-9]{55}$/)
end