Android Question Get all domain names using java code

PdeG

Member
Licensed User
Longtime User
Hi all,
I need to retrieve all subdomain from a domain, a friend provided a JAVA function, I need this function to return a list of domain names.
Can someone help me to implement the function in a #IF JAVA that return a list or array with domain names.

TIA Peter

Java:
void updateDnsList(){
    // start a thread and do the DNS request
    final AsyncTask<Void, Void, String[]> xxx = new AsyncTask<Void, Void, String[]>() {
        @Override
        protected String[] doInBackground(Void... params) {
            Vector<String> listResult = new Vector<String>();
            try {
                // add all round robin servers one by one to select them separately
                InetAddress[] list = InetAddress.getAllByName("some.domain.com");
                for (InetAddress item : list) {
                    listResult.add(item.getCanonicalHostName());
                }
            } catch (UnknownHostException e) {
                e.printStackTrace();
            }
            return listResult.toArray(new String[0]);
        }

        @Override
        protected void onPostExecute(String[] result) {
            // do something with the result
            super.onPostExecute(result);
        }
    }.execute();
}
 
Last edited:

Sandman

Expert
Licensed User
Longtime User
I need to retrieve all subdomain from a domain, a friend provided a JAVA function
Not really possible unless you do some brute forcing. Your function won't work.

 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
👍 but Google search like site:ford.com often gives a good head-start 🍻
I've never had any luck with that, when trying to find subdomains. I tend to use a tool like this:

Checking subdomains for whitehouse.gov gave 35 subdomains:

There's a reason why there are dedicated sites for this. It's not a dead simple problem to get this information.
 
Upvote 0
Top