This repository has been archived by the owner on Oct 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
125 lines (106 loc) · 4.31 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<!DOCTYPE html>
<html>
<head>
<title>WannaCry Profits</title>
<meta charset="utf-8">
<meta description="Track the WannaCry ransomware's profits in real time.">
<link href="style.css" rel="stylesheet" media="screen" />
</head>
<body>
<h1>WannaCry Profits</h1>
<p>Stats for each known BTC address associated with the <a href="https://en.wikipedia.org/wiki/WannaCry_ransomware_attack">WannaCry ransomware</a>:</p>
<br>
<?php
//all known BTC addresses associated with WannaCry
$addresses = array(
"12t9YDPgwueZ9NyMgw519p7AA8isjr6SMw",
"115p7UMMngoj1pMvkpHijcRdfJNXj6LrLn",
"13AM4VW2dhxYgXeQepoHkHSQuy6NgaEb94",
"1QAc9S5EmycqjzzWDc1yiWzr9jJLC8sLiY",
"15zGqZCTcys6eCjDkE3DypCjXi6QWRV6V1"
);
//blockchain api URL
$btcAPI = "https://blockchain.info/multiaddr?active=";
//USD price URL
$usdAPI = "https://api.coinbase.com/v2/prices/spot?currency=USD";
//append addersses to blockchain API call
foreach($addresses as $addr){
$btcAPI = $btcAPI . $addr;
$btcAPI = $btcAPI . "|";
}
//remove extra "|" from blockchain API call
$btcAPI = rtrim($btcAPI, '|');
//make API call to blockchain
$btcRawData = file_get_contents($btcAPI);
$btcData = json_decode($btcRawData, true)['addresses'];
//make API call to coinbase price api
$usdRawData = file_get_contents($usdAPI);
$usdPrice = json_decode($usdRawData, true)['data']['amount'];
//create running total BTC
$totalBTC = 0;
for ($i = 0; $i < count($addresses); $i++){
//get total btc for currently selected address
$currentTotal = $btcData[$i]['total_received'];
//format current total to correct API data for satoshi values -> -8
$currentTotal = substr_replace($currentTotal, ".", -8, -8);
//compute total USD value for selected address
$usdValue = number_format($usdPrice * $currentTotal, 2);
//add total for currently selected address to running total
$totalBTC = $totalBTC + $currentTotal;
//template HTML containing address stats
echo
"<div>\n" .
"<span>Blockchain Address: " .
"<a class = \"btcaddress\" href=\"https://blockchain.info/address/" . $btcData[$i]['address'] . "\">" . $btcData[$i]['address'] . "</a>" .
"</span>\n" .
"<span class=\"btcaddress\">" .
"</span>" .
"</div>\n" .
"<br>\n" .
"<div>\n" .
"<span>Current BTC Value: </span>\n" .
"<span class=\"addrvalue\">" . $currentTotal . " BTC</span>" .
"</div>\n" .
"<br>\n" .
"<div>\n" .
"<span>Current USD Value: </span>\n" .
"<span class=\"usdvalue\">$" . $usdValue . "</span>\n" .
"</div>\n" .
"<br>\n" .
"<br>\n"
;
}
//compute total USD value of total BTC count
$totalUSD = $totalBTC * $usdPrice;
//compute possible number of ransoms paid
$totalRansomsPaid = $totalUSD / 300;
//format totals for readability
$totalUSD = number_format($totalUSD, 2);
$totalRansomsPaid = number_format($totalRansomsPaid);
//template HTML containing overall totals
echo
"<div class =\"highlights\">\n" .
"<span>Estimated WannaCry ransoms paid (assuming $300 USD per infection): </span>\n" .
"<span class=\"addrvalue\">" . $totalRansomsPaid . "</span>\n" .
"<br>\n" .
"<br>\n" .
"<span>Total BTC spent by WannaCry victims: </span>\n" .
"<span class=\"addrvalue\">" . $totalBTC . " BTC</span>\n" .
"<br>\n" .
"<br>\n" .
"<span>Current USD equivalent total: </span>\n" .
"<span class=\"usdvalue\">$" . $totalUSD . "</span>\n" .
"</div>";
?>
<p>* USD prices for BTC are obtained from <a href="https://coinbase.com">CoinBase</a>.</p>
<br>
<p>This website was built as a favor to the digital community by <a href="http://stevenbock.me">Steven Bock</a>.</p>
<p>If you have any questions or comments, feel free to contact me via <a href="mailto:[email protected]">eMail</a> or on <a href="https://twitter.com/dabockster">Twitter</a>.
<p>You can also follow further development of this site on <a href="https://github.com/dabockster/WannaCryProfits">GitHub</a>.</p>
<br>
<p>If you found this information useful, consider tipping me some BTC.</p>
<p>1JwAifJtE9SXocZe2MvXTK1pdbCHPYwFVY</p>
<!-- Scripts go below this line -->
<script src="./js/analytics.js" />
</body>
</html>