Skip to content

Instantly share code, notes, and snippets.

@Arinerron
Last active August 7, 2021 09:08
Show Gist options
  • Save Arinerron/53b48d1e6d99f2720a7e300d3e2bc447 to your computer and use it in GitHub Desktop.
Save Arinerron/53b48d1e6d99f2720a7e300d3e2bc447 to your computer and use it in GitHub Desktop.
Scrape BTC accounts and their balance. If you see one that isn't 0.0, go to the first URL that it prints somewhere above the BTC account, and you can get the private key for that account from the page.
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
public class Main {
public static void main(String[] args) throws Exception {
for(long i = 0; i < Long.MAX_VALUE; i++) {
System.out.println("\n[ " + "http://directory.io/" + i + " ]");
for(String s : getBTC(i))
System.out.println(s + " has " + getBalance(s));
}
}
public static List<String> getBTC(long index) throws Exception {List<String> list = new ArrayList<>();for(String s : getText("http://directory.io/" + index).split(Pattern.quote("https://blockchain.info/address/")))if(!s.endsWith("</span> <a href=\"") && !s.endsWith("</html>"))list.add(s.split(Pattern.quote("\">"))[0]);List<String> list2 = new ArrayList<>();for(String s : list)if(s.length() == 33)list2.add(s + " ");else list2.add(s);list = null;return list2;}
public static double getBalance(String address) throws Exception {return Double.parseDouble(getText("https://blockchain.info/address/" + address).split(Pattern.quote("<td id=\"final_balance\"><font color=\"green\"><span data-c=\""))[1].split(Pattern.quote("\""))[0]);}
public static String getText(String url) throws Exception {System.setProperty("http.agent", "");URLConnection connection = new URL(url).openConnection();connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2");BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));StringBuilder response = new StringBuilder();String inputLine;while ((inputLine = in.readLine()) != null)response.append(inputLine);in.close();return response.toString();}
}
@quinnoaj
Copy link

quinnoaj commented Nov 7, 2017

Hello, I tried to compile the code online and I get the following errors:
[ http://directory.io/0 ] Exception in thread "main" java.net.UnknownHostException: directory.io at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at java.net.Socket.connect(Socket.java:538) at sun.net.NetworkClient.doConnect(NetworkClient.java:180) at sun.net.www.http.HttpClient.openServer(HttpClient.java:463) at sun.net.www.http.HttpClient.openServer(HttpClient.java:558) at sun.net.www.http.HttpClient.<init>(HttpClient.java:242) at sun.net.www.http.HttpClient.New(HttpClient.java:339) at sun.net.www.http.HttpClient.New(HttpClient.java:357) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1202) at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1138) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1032) at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:966) at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1546) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474) at Main.getText(Main.java:20) at Main.getBTC(Main.java:18) at Main.main(Main.java:13) exited with non-zero status

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment