11.30.41 Mengetahui Informasi Localhost | |
Mengetahui Informasi Localhost
Sebelum kita menyerang target, pastinya kita telah mengenal parameter(IP Address, MAC Address, dll) komputer kita di jaringan, sehingga mempermudah kita dalam menyerang target. Kenali Dirimu Sebelum Kamu Mencari Tahu Targetmu. Mengetahui IP Localhost Nama file -> InternetAddressing.java Code: Select all import java.net.*;
public class InternetAddressing { public static void main(String args[]) { try { InetAddress ip=InetAddress.getLocalHost(); System.out.println(ip.toString()); } catch (Exception e) { e.printStackTrace(); } } } Mengetahui Nama Host (Host Name) Komputer kita (Localhost) Nama file -> HostName.java Code: Select all import java.net.*; import java.io.*; import java.util.*;
public class HostName { public static void main(String args[]) { try { InetAddress a=InetAddress.getLocalHost(); System.out.println(a.getHostName()); } catch (Exception e) {
} } } Mengetahui MAC Address kita sendiri Nama file -> MacAddress.java Code: Select all import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.net.UnknownHostException;
public class MacAddress {
public static void main(String[] args) { try { InetAddress address = InetAddress.getLocalHost();
/* * Get NetworkInterface for the current host and then read the * hardware address. */ NetworkInterface ni = NetworkInterface.getByInetAddress(address); byte[] mac = ni.getHardwareAddress();
/* * Extract each array of mac address and convert it to hexa with the * following format 08-00-27-DC-4A-9E. */ for (int i = 0; i < mac.length; i++) { System.out.format("%02X%s", mac[0], (i < mac.length - 1) ? "-" : ""); } } catch (UnknownHostException e) { e.printStackTrace(); } catch (SocketException e) { e.printStackTrace(); } } } Atau silahkan coba Source code dibawah ini Nama file -> GetMac.java Code: Select all import java.io.*; import java.net.*; import java.util.*; import java.util.regex.*;
public class GetMac { public static void main(String[] args) throws IOException { String address = new GetMac().getMacAddress(); System.out.println(address); }
public String getMacAddress() throws IOException { String macAddress = null; String command = "ipconfig /all"; Process pid = Runtime.getRuntime().exec(command); BufferedReader in = new BufferedReader(new InputStreamReader(pid.getInputStream())); while (true) { String line = in.readLine(); if (line == null) break; Pattern p = Pattern.compile(".*Physical Address.*: (.*)"); Matcher m = p.matcher(line); if (m.matches()) { macAddress = m.group(1); break; } } in.close(); return macAddress; } } Lebih lanjut, dengan program dibawah ini kita juga dapat mengidentifikasi OS beserta network info. Program ini dapat mengidentifikasi windows OS dan Linux OS. Nama file -> NetworkInfo Code: Select all /** try to determine MAC address of local network card; this is done using a shell to run ifconfig (linux) or ipconfig (windows). The output of the processes will be parsed.
<p>
To run the whole thing, just type java NetworkInfo
<p>
Current restrictions:
<ul> <li>Will probably not run in applets
| |
|
Total comments: 1 | ||
| ||