Last active
August 28, 2016 11:36
-
-
Save jmerle/cd82f5fa09e09b5ebaa479260728c10c to your computer and use it in GitHub Desktop.
HE IP Checker is a little userscript that checks IP addresses for their types and if they exist. You can do a maximum of 2,500 IP's at once (to prevent IP brute-forcing). It injects into the breadcrumb bar, and the input window opens when you click the link the 'Check IP's' link just beneath where your bank money is shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name HE IP Checker | |
// @namespace http://tampermonkey.net/ | |
// @version 1.0.0 | |
// @description HE IP Checker is a little userscript that checks IP addresses for their types and if they exist. You can do a maximum of 2,500 IP's at once (to prevent IP brute-forcing). It injects into the breadcrumb bar, and the input window opens when you click the link the 'Check IP's' link just beneath where your bank money is shown. | |
// @author Jasper van Merle | |
// @match https://*.hackerexperience.com/* | |
// @grant none | |
// @require https://code.jquery.com/jquery-3.1.0.min.js | |
// @require https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js | |
// ==/UserScript== | |
var gritterLoaded = false; | |
var linkToInject = '<span class="pull-right hide-phone"><a href="javascript:void(0)" id="ipCheckLink">Check IP\'s</a></span>'; | |
var inputModal = '<div class="fade modal"role=dialog id=inputModal tabindex=-1><div class=modal-dialog role=document><div class=modal-content><div class=modal-header><button class=close type=button data-dismiss=modal aria-label=Close><span aria-hidden=true>×</span></button><h4 class=modal-title>Check IP\'s (made by <a href="https://legacy.hackerexperience.com/profile?id=510033"target=_blank>Jasperr</a>)</h4></div><form id=inputForm><div class=modal-body><div class=form-group><label class=control-label for=ipInput>Please input your IP\'s below, one per line and it will give you back all existing VPC\'s and Clan IP\'s.</label><textarea class=form-control id=ipInput placeholder="Place your IP\'s here"rows=10 style=min-width:90%></textarea></div></div><div class=modal-footer><button class="btn btn-default"type=button data-dismiss=modal>Close</button> <button class="btn btn-primary"type=submit id=inputSubmitButton>Check my IP\'s</button></div></form></div></div></div>'; | |
var isChecking = false; | |
var totalChecked = 0; | |
var totalIPsToCheck = 0; | |
var nonExisting = 0; | |
var NPCs = []; | |
var VPCs = []; | |
var ClanServers = []; | |
var IPsToCheck = []; | |
function gritterNotify(opts) { | |
if (!gritterLoaded) { | |
$('<link rel="stylesheet" type="text/css" href="css/jquery.gritter.css">').appendTo("head"); | |
$.getScript("js/jquery.gritter.min.js", function() { | |
$.gritter.add({ | |
title: opts.title, | |
text: opts.text, | |
image: opts.img, | |
sticky: opts.sticky | |
}); | |
}); | |
gritterLoaded = true; | |
return; | |
} | |
$.gritter.add({ | |
title: opts.title, | |
text: opts.text, | |
image: opts.img, | |
sticky: opts.sticky | |
}); | |
} | |
function validateIP(ipaddress) { | |
if (/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(ipaddress)) { | |
return true; | |
} | |
return false; | |
} | |
function isLoggedIn() { | |
if ($('a[href="logout"]').length) { | |
return true; | |
} | |
return false; | |
} | |
function bindLinkEvent() { | |
$('#ipCheckLink').click(function(event) { | |
ipCheckLinkClick(event); | |
}); | |
} | |
function unbindLinkEvent() { | |
$('#ipCheckLink').off('click'); | |
} | |
function ipCheckLinkClick(event) { | |
$('#inputModal').modal('show'); | |
$(".modal-backdrop").removeClass("modal-backdrop"); | |
} | |
function checkIPs(ipArray) { | |
if (!isChecking) { | |
isChecking = true; | |
totalChecked = 0; | |
nonExisting = 0; | |
NPCs = []; | |
VPCs = []; | |
ClanServers = []; | |
totalIPsToCheck = ipArray.length; | |
console.log(ipArray); | |
IPsToCheck = ipArray; | |
checkIPArray(); | |
} | |
} | |
function checkIPArray() { | |
if (totalChecked == totalIPsToCheck) { | |
finishSubmit(); | |
return; | |
} | |
var ip = IPsToCheck[0]; | |
IPsToCheck.splice(0, 1); | |
$.get('https://legacy.hackerexperience.com/internet?ip=' + ip, function(data) { | |
if ($('.widget-content:contains("404")', data).length) { | |
nonExisting++; | |
} else { | |
var type = $('.label.pull-right', data).text(); | |
switch (type) { | |
case 'NPC': | |
NPCs.push(ip); | |
break; | |
case 'VPC': | |
VPCs.push(ip); | |
break; | |
case 'Clan Server': | |
ClanServers.push(ip); | |
break; | |
default: | |
NPCs.push(ip); | |
} | |
} | |
totalChecked++; | |
checkIPArray(); | |
}); | |
} | |
function submitInput() { | |
$('#inputSubmitButton').prop('disabled', true); | |
$('#inputSubmitButton').text('Working on it'); | |
var IPs = $('#ipInput').val().split('\n'); | |
var IPs = IPs.filter(function(elem, index, self) { | |
return index == self.indexOf(elem); | |
}); | |
var validIPs = []; | |
$.each(IPs, function(index, value) { | |
if (validateIP(value)) { | |
validIPs.push(value); | |
} | |
}); | |
var amount = validIPs.length; | |
if (amount == 0) { | |
gritterNotify({ | |
title: 'HE IP Checker', | |
text: 'You didn\'t input any IP\'s or all your IP\'s were invalid.', | |
image: '', | |
sticky: false | |
}); | |
$('#inputSubmitButton').prop('disabled', false); | |
isChecking = false; | |
$('#inputSubmitButton').text('Check my IP\'s'); | |
return; | |
} | |
if (amount > 2500) { | |
gritterNotify({ | |
title: 'HE IP Checker', | |
text: 'You can only check 2500 IP\'s at a time.', | |
image: '', | |
sticky: false | |
}); | |
$('#inputSubmitButton').prop('disabled', false); | |
isChecking = false; | |
$('#inputSubmitButton').text('Check my IP\'s'); | |
return; | |
} | |
checkIPs(validIPs); | |
} | |
function finishSubmit() { | |
var text = 'Checked ' + totalIPsToCheck + ' IP\'s of which ' + nonExisting + ' didn\'t exist. There were ' + NPCs.length + ' NPC\'s, ' + VPCs.length + ' VPC\'s and ' + ClanServers.length + ' Clan servers.'; | |
if (NPCs.length > 0) { | |
text += '\n\nNPC IP\'s (' + NPCs.length + ')\n\n'; | |
text += NPCs.join('\n'); | |
} | |
if (VPCs.length > 0) { | |
text += '\n\nVPC IP\'s (' + VPCs.length + ')\n\n'; | |
text += VPCs.join('\n'); | |
} | |
if (ClanServers.length > 0) { | |
text += '\n\nClan Server IP\'s (' + ClanServers.length + ')\n\n'; | |
text += ClanServers.join('\n'); | |
} | |
$('#ipInput').val(text); | |
$('#inputSubmitButton').prop('disabled', false); | |
isChecking = false; | |
$('#inputSubmitButton').text('Check my IP\'s'); | |
} | |
$(document).ready(function() { | |
if (isLoggedIn()) { | |
$('#breadcrumb').append(linkToInject); | |
$('body').append(inputModal); | |
$('#inputForm').submit(function(event) { | |
event.preventDefault(); | |
submitInput(); | |
}); | |
bindLinkEvent(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment