Advertisement
Guest User

Untitled

a guest
Sep 8th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.24 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Hexperience Tools
  3. // @namespace https://github.com/lee8oi/hexperience
  4. // @version 0.9.1
  5. // @description Advanced helper tools for Hacker Experience Legacy.
  6. // @author lee8oi
  7. // @match *://legacy.hackerexperience.com/*
  8. // @run-at document-end
  9. // @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js
  10. // @grant GM_setValue
  11. // @grant GM_getValue
  12. // @grant GM_addStyle
  13. // @grant GM_listValues
  14. // @grant GM_deleteValue
  15. // ==/UserScript==
  16.  
  17. /*
  18. Auto hide-me
  19. */
  20.  
  21. function hideMe() {
  22. var logArea = $('form.log').find('.logarea'), val = logArea.val(), myIp = GM_getValue("myIp");
  23. if (typeof(val) != "undefined" && val.length > 0) {
  24. var logLines = val.split('\n'), newLines = [], foundIP = false;
  25. $.each(logLines, function(i, el) {
  26. if (el.indexOf(myIp) != -1) {
  27. foundIP = true;
  28. } else {
  29. if (el.trim().length > 0) newLines.push(el);
  30. }
  31. });
  32. if (foundIP) {
  33. logArea.val(newLines.join('\n'));
  34. $('form.log').submit();
  35. }
  36. }
  37. }
  38.  
  39. /*
  40. Update my IP
  41. */
  42.  
  43. setTimeout(function(){
  44. var myIp = $('.header-ip-show').text();
  45. var storedIp = GM_getValue("myIp");
  46. if (storedIp != myIp) {
  47. GM_setValue("myIp", myIp);
  48. }
  49. }, 500);
  50.  
  51. if (window.location.href.indexOf("internet") != -1) {
  52. if (!GM_getValue("myIp")) {
  53. setTimeout(hideMe, 500);
  54. } else {
  55. hideMe();
  56. }
  57. }
  58.  
  59. /*
  60. IP database
  61. */
  62.  
  63. function loadIpLogs(dbName) {
  64. if (!GM_getValue(dbName) ) {
  65. GM_setValue(dbName, "{}");
  66. }
  67. var text = GM_getValue(dbName), db = JSON.parse(text);
  68. var getBtns = function (i) {
  69. var savedLink = '<a href="#" id="saveip" name="' + i + '">[save]</a>';
  70. var ignoreLink = '<a href="#" id="ignoreip" name="' + i + '">[ignore]</a>';
  71. if (dbName == "savedDb") savedLink = "";
  72. if (dbName == "ignoreDb") ignoreLink = "";
  73. return '<a href="#" id="deleteip" name="' + i + '">[delete]</a> ' + savedLink + ' ' + ignoreLink + ' <a href="http://legacy.hackerexperience.com/internet?ip=' + i +'&action=hack&method=bf" id="bruteip" name="' +
  74. i + '">[brute]</a>';
  75. };
  76. for (var i in db) {
  77. if (db.hasOwnProperty(i)) {
  78. $('#logdblist').append('<div id="' + i + '"><a href="http://legacy.hackerexperience.com/internet?ip=' + i + '" id="loadlocal" name="' + i + '">' + i + '</a>&nbsp;&nbsp;&nbsp;' +
  79. getBtns(i) + '</br></div>');
  80. }
  81. }
  82. GM_addStyle('#logdblist a#loadlocal {float: left;}');
  83. GM_addStyle('#logdblist a#deleteip, #logdblist a#bruteip, #logdblist a#saveip {float: right;}');
  84. if (dbName != "ignoreDb") {
  85. GM_addStyle('#logdblist a#ignoreip {float: right;}');
  86. }
  87. var removeFromAll = function (name) {
  88. var local = JSON.parse(GM_getValue("localDb")),
  89. internet = JSON.parse(GM_getValue("internetDb")),
  90. ignore = JSON.parse(GM_getValue("ignoreDb")),
  91. saved = JSON.parse(GM_getValue("savedDb"));
  92. delete internet[name];
  93. delete local[name];
  94. delete ignore[name];
  95. delete saved[name];
  96. GM_setValue("localDb", JSON.stringify(local));
  97. GM_setValue("internetDb", JSON.stringify(internet));
  98. GM_setValue("ignoreDb", JSON.stringify(ignore));
  99. GM_setValue("savedDb", JSON.stringify(saved));
  100. };
  101. $('a[id=deleteip]').click(function () {
  102. var name = $(this).attr('name');
  103. removeFromAll(name);
  104. $('div[id="'+ name +'"]').remove();
  105. });
  106. if (dbName != "ignoreDb") {
  107. $('a[id=ignoreip]').click(function () {
  108. var name = $(this).attr('name');
  109. removeFromAll(name);
  110. $('div[id="'+ name +'"]').remove();
  111. var dbig = JSON.parse(GM_getValue("ignoreDb"));
  112. if (!dbig[name]) dbig[name] = true;
  113. GM_setValue("ignoreDb", JSON.stringify(dbig));
  114. });
  115. }
  116. if (dbName != "savedDb") {
  117. $('a[id=saveip]').click(function () {
  118. var name = $(this).attr('name'), saved = {}, saveText = GM_getValue("savedDb");
  119. if (!saveText) saveText = "{}";
  120. saved = JSON.parse(saveText);
  121. removeFromAll(name);
  122. $('div[id="'+ name +'"]').remove();
  123. if (!saved[name]) saved[name] = true;
  124. GM_setValue("savedDb", JSON.stringify(saved));
  125. });
  126. }
  127. }
  128.  
  129. function setupIpDbPage(dbtype, dbname, dbKey) {
  130. /*jshint multistr: true */
  131. $('.widget-content').html('\
  132. <div class="span12">\
  133. <div class="widget-box text-left" style="margin-left: auto;margin-right: auto; width: 400px;">\
  134. <div class="widget-title"><span class="icon"><span class="he16-collect_info"></span></span>\
  135. <h5>Select ' + dbname + ' IP</h5>\
  136. <button type="button" id="wipedb" key="'+dbKey+'" style="position:absolute;right:10px;top:5px;">Wipe</button>\
  137. </div>\
  138. <div class="widget-content ' + dbtype + 'ipdb"><div id="logdblist"></div></div>\
  139. </div>\
  140. </div>' );
  141. GM_addStyle('#logdblist { max-height: 400px; overflow: auto; padding: 5px; }');
  142.  
  143. $('#wipedb').click(function() {
  144. var key = $(this).attr('key');
  145. $('#logdblist').text("");
  146. GM_deleteValue(key);
  147. });
  148.  
  149. }
  150.  
  151. function ipDBPage(){
  152. document.title = 'IP Database';
  153. $('.nav.nav-tabs:first').html('<li class="link active" id="tabweb"><a href="#" id="weblog"><span class="icon-tab he16-internet_log"></span>Internet</a></li>');
  154. $('.nav.nav-tabs:first').append('<li class="link" id="tablocal"><a href="#" id="locallog"><span class="icon-tab he16-internet_log"></span>Local</a></li>');
  155. $('.nav.nav-tabs:first').append('<li class="link" id="tabsaved"><a href="#" id="savedlog"><span class="icon-tab he16-internet_log"></span>Saved</a></li>');
  156. $('.nav.nav-tabs:first').append('<li class="link" id="tabignore"><a href="#" id="ignorelog"><span class="icon-tab he16-internet_log"></span>Ignored</a></li>');
  157. $('.label.label-info').remove();
  158. $('#link0').attr('href','log?ipdb'); $('#link0').html('IPDB');
  159. $('#content-header h1').html('IP Database');
  160. setupIpDbPage('internet', 'Internet', 'internetDb');
  161. loadIpLogs("internetDb");
  162. }
  163.  
  164. if (window.location.href.search('ipdb') > 0) {
  165. $('#sidebar ul li.active').attr('class','');
  166. $('#sidebar ul').append('<li class="active"><a href="log?ipdb"><i class="fa fa-inverse fa-list-ul"></i> <span>IP Database</span></a></li>');
  167. ipDBPage();
  168. } else {
  169. $('#sidebar ul').append('<li><a href="log?ipdb"><i class="fa fa-inverse fa-list-ul"></i> <span>IP Database</span></a></li>');
  170. }
  171. GM_addStyle('.fa-list-ul {content: "\f0ca";}');
  172.  
  173. $('#tablocal').click(function() {
  174. $('#tablocal').attr('class','link active');
  175. $('#tabweb').attr('class','link');
  176. $('#tabignore').attr('class','link');
  177. $('#tabsaved').attr('class', 'link');
  178. setupIpDbPage('local', 'Local', 'localDb');
  179. loadIpLogs("localDb");
  180. });
  181.  
  182. $('#tabweb').click(function() {
  183. $('#tabweb').attr('class','link active');
  184. $('#tablocal').attr('class','link');
  185. $('#tabignore').attr('class','link');
  186. $('#tabsaved').attr('class', 'link');
  187. setupIpDbPage('web', 'Internet', 'internetDb');
  188. loadIpLogs("internetDb");
  189. });
  190.  
  191. $('#tabsaved').click(function() {
  192. $('#tabweb').attr('class','link ');
  193. $('#tablocal').attr('class','link');
  194. $('#tabignore').attr('class','link');
  195. $('#tabsaved').attr('class', 'link active');
  196. setupIpDbPage('save', 'Saved', 'savedDb');
  197. loadIpLogs("savedDb");
  198. });
  199.  
  200. $('#tabignore').click(function() {
  201. $('#tabignore').attr('class','link active');
  202. $('#tablocal').attr('class','link');
  203. $('#tabweb').attr('class','link');
  204. $('#tabsaved').attr('class', 'link');
  205. setupIpDbPage('ignore', 'Ignored', 'ignoreDb');
  206. loadIpLogs("ignoreDb");
  207. });
  208.  
  209. /*
  210. Alert handling
  211. */
  212.  
  213. function alertText() {
  214. var alertArray = $(".alert.alert-success").text().split("\n");
  215. var aText = alertArray.filter(function(val) {
  216. return val.length > 1;
  217. });
  218. if (aText.length > 0) {
  219. return aText[0].trim();
  220. } else {
  221. return;
  222. }
  223. }
  224.  
  225. function successAlert(text) {
  226. if (text) {
  227. switch (true) {
  228. case text === "Success! Software installed.":
  229. return true;
  230. case text === "Success! Software successfully hidden.":
  231. return true;
  232. case text === "Success! Software successfully uploaded.":
  233. return true;
  234. case text === "Success! Software successfully deleted.":
  235. return true;
  236. case text === "Success! Software successfully downloaded.":
  237. return true;
  238. case text === "Success! Software successfully seeked.":
  239. return true;
  240. case text.indexOf("virus removed") != -1:
  241. return true;
  242. case text.indexOf("viruses removed") != -1:
  243. return true;
  244. }
  245. }
  246. return false;
  247. }
  248.  
  249. // Switch to logs on success alert (to trigger auto hideme)
  250. if (window.location.href.indexOf("internet") != -1 && successAlert(alertText())) {
  251. window.location.replace("http://legacy.hackerexperience.com/internet?view=logs");
  252. }
  253.  
  254. if (window.location.href.indexOf("software") != -1 && alertText() === "Success! Software successfully downloaded.") {
  255. window.location.replace("http://legacy.hackerexperience.com/internet?view=logs");
  256. }
  257.  
  258. /*
  259. Clear log buttons
  260. */
  261.  
  262. if ($('#link2').text() == " Log file" || $('#link0').text() == " Log File" || $('#link2').text() == " Log File") {
  263. $('form.log input.btn').before('<input class="btn btn-inverse" id="clearlog" type="button" value="Clear" style="width: 80px;"><span> </span>');
  264. }
  265.  
  266. $('#clearlog').click(function(){
  267. if ($('form.log').length) {
  268. $('form.log').find('.logarea').val('');
  269. $('form.log').submit();
  270. } else {
  271. console.log('No log found');
  272. }
  273. });
  274.  
  275. /*
  276. Hacked Database mods
  277. */
  278.  
  279. function toggleFavorite(ip, elem) {
  280. var favorites = JSON.parse(GM_getValue("favorites"));
  281. if (favorites[ip]) {
  282. delete favorites[ip];
  283. elem.removeClass("fa-star");
  284. elem.addClass("fa-star-o");
  285. } else {
  286. favorites[ip] = true;
  287. elem.removeClass("fa-star-o");
  288. elem.addClass("fa-star");
  289. }
  290. GM_setValue("favorites", JSON.stringify(favorites));
  291. }
  292.  
  293. if (window.location.href.indexOf("legacy.hackerexperience.com/list") != -1 ) {
  294. GM_addStyle('.fa-star {content: "\f005";}');
  295. GM_addStyle('.fa-star-o {content: "\f006";}');
  296. GM_addStyle('i.favorite {color: #DAA520;}');
  297. var favText = GM_getValue("favorites"), favorites = {};
  298. if (!favText) {
  299. GM_setValue("favorites", "{}");
  300. }
  301. favorites = JSON.parse(GM_getValue("favorites"));
  302. $("ul.list.ip li").each(function(){
  303. var entry = $(this);
  304. var pass = $(this).find(".list-user span.small").get(1).firstChild.data;
  305. var url = $(this).find(".list-ip a").attr("href") + "&action=login&user=root&pass=" + pass;
  306. $(this).find(".list-ip").after(' <a href="' + url + '" style="float:left;margin: 5px 5px 0px 5px;font-size:14px">[login]</a>');
  307. console.log(url);
  308. var ip = entry.find(".list-ip #ip").text();
  309. if (favorites[ip]) {
  310. entry.find(".list-actions").append('<i class="favorite fa-2x fa fa-inverse fa-star"></i>');
  311. } else {
  312. entry.find(".list-actions").append('<i class="favorite fa-2x fa fa-inverse fa-star-o"></i>');
  313. }
  314. entry.find("i.favorite").click(function () {
  315. toggleFavorite(ip, $(this));
  316. });
  317. });
  318. }
  319.  
  320. /*
  321. Log monitor (ip-scraper will grab any IP's)
  322. */
  323.  
  324. function refreshPage(){
  325. if (window.location.href.search('ipdb') > 0) return; //dont refresh ipdb
  326. if (GM_getValue(window.location.pathname + "monitorLog")) {
  327. location.reload();
  328. }
  329. }
  330.  
  331. function Regs() {
  332. this.generating = /Server\s\[\d+\.\d+\.\d+\.\d+\].*(mined|mailed).*generating.*/;
  333. this.transfer = /.*(Funds|)were transferred (to|).*/;
  334. this.collected = /.*localhost collected.*/;
  335. this.login = /^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2} - localhost logged.*on account.*/;
  336. this.bought = /.*localhost bought license.*/;
  337. this.research = /.*localhost researched.*/;
  338. }
  339.  
  340. var localRegs = new Regs();
  341. var fullRegs = new Regs();
  342. fullRegs.localhost = /^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}\s-\slocalhost.*/;
  343.  
  344. function checkLine(line, regObj) {
  345. for (var prop in regObj) {
  346. if (line.match(regObj[prop])) {
  347. return true;
  348. }
  349. }
  350. return false;
  351. }
  352.  
  353. function scrapeLog() {
  354. var logArea = $('form.log').find('.logarea'), logText = logArea.val(), logsFound = false, logResult = [];
  355. var stored = [], storedText = GM_getValue(window.location.pathname + "storedLogs");
  356. if (!storedText) storedText = "";
  357. if (storedText.length > 0) stored = storedText.split("\n");
  358. if (logText !== "undefined" && logText.length > 0) {
  359. var split = logText.split("\n");
  360. for (i = 0; i < split.length; i++) {
  361. var line = split[i].trim();
  362. if (line.length === 0) continue;
  363. if (window.location.pathname === "/log") {
  364. if (checkLine(line, localRegs) === true) logsFound = true;
  365. else logResult.push(line);
  366. }
  367. console.log(stored.indexOf(line) + " " + line);
  368. if (stored.indexOf(line) === -1 && line.length > 0 && checkLine(line, fullRegs) === false) {
  369. console.log("Pushing line" + line);
  370. stored.push(line);
  371. }
  372. }
  373. if (stored.length > 0) GM_setValue(window.location.pathname + "storedLogs", stored.join("\n").trim());
  374. }
  375. if (logsFound) {
  376. logArea.val(logResult.join("\n"));
  377. $('form.log').submit();
  378. }
  379. }
  380.  
  381. if ($('#cf-error-details h2[data-translate="what_happened"]').text().trim().length > 0) { //detect cloudflare error
  382. setTimeout(refreshPage, 3000);
  383. }
  384.  
  385. if (GM_getValue(window.location.pathname + "monitorLog")) {
  386. console.log("started backup timeout");
  387. setTimeout(refreshPage, 30000);//backup page refresher
  388. }
  389.  
  390. if ($('#link0').text() == " Log File" || $('#link2').text() == " Log file" || $('#link2').text() == " Log File") {
  391. var monitor = GM_getValue(window.location.pathname + "monitorLog");
  392. if (monitor === "undefined") {
  393. GM_setValue(window.location.pathname + "monitorLog", false);
  394. monitor = false;
  395. }
  396. var addClick = function () {
  397. $('form.log #logmonitor').click(function () {
  398. monitor = true;
  399. GM_setValue(window.location.pathname + "monitorLog", true);
  400. $('input#logmonitor').attr("value", "Stop");
  401. setTimeout(refreshPage, 3000);
  402. });
  403. };
  404. if (monitor) {
  405. $('form.log input#clearlog').before('<input class="btn btn-inverse" id="logmonitor" type="button" value="Stop" style="width: 80px;"><span> </span>');
  406. $('form.log #logmonitor').click(function () {
  407. GM_setValue(window.location.pathname + "monitorLog", false);
  408. $('input#logmonitor').attr("value", "Monitor");
  409. monitor = false;
  410. addClick();
  411. $("textarea.logarea").val(GM_getValue(window.location.pathname + "storedLogs"));
  412. GM_setValue(window.location.pathname + "storedLogs", "");
  413. });
  414. scrapeLog();
  415. setTimeout(refreshPage, 3000);
  416. setTimeout(refreshPage, 7000);//backup refresher for hangs
  417. } else {
  418. $('form.log #clearlog').before('<input class="btn btn-inverse" id="logmonitor" type="button" value="Monitor" style="width: 80px;"><span> </span>');
  419. addClick();
  420. }
  421. }
  422.  
  423. /*
  424. Auto ip-scraper
  425. */
  426.  
  427. function uniqueArray(arr) {
  428. var unique = [], map = [];
  429. for (var i in arr) {
  430. if (map[arr[i]]) {
  431. continue;
  432. } else {
  433. map[arr[i]] = true;
  434. unique[unique.length] = arr[i];
  435. }
  436. }
  437. return unique;
  438. }
  439.  
  440. function scrapeIPs(text) {
  441. if (typeof(text) === "string") {
  442. var re = /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/g;
  443. var found = text.match(re);
  444. if (found && found.length > 0) {
  445. return uniqueArray(found);
  446. }
  447. }
  448. return;
  449. }
  450.  
  451. function saveIPs(dbName, ipArray) {
  452. if (typeof(ipArray) == "object" && ipArray.length > 0) {
  453. var dbText = GM_getValue(dbName), myIp = GM_getValue("myIp"), igText = GM_getValue("ignoreDb"),
  454. saveText = GM_getValue('savedDb');
  455. var db = {};
  456. if (igText && igText.length > 0) igDb = JSON.parse(igText);
  457. if (saveText && saveText.length > 0) saveDb = JSON.parse(saveText);
  458. if (dbText && typeof(dbText) === 'string' && dbText.length > 0) {
  459. db = JSON.parse(dbText);
  460. for (i = 0; i < ipArray.length;i++) {
  461. if (ipArray[i] == myIp || igDb[ipArray[i]] || saveDb[ipArray[i]]) continue;
  462. if (!db[ipArray[i]] ) db[ipArray[i]] = true;
  463. }
  464. } else {
  465. for (i = 0; i < ipArray.length;i++) {
  466. if (ipArray[x] == myIp || igDb[ipArray[x]]) continue;
  467. db[ipArray[x]] = true;
  468. }
  469. }
  470. var json = JSON.stringify(db);
  471. GM_setValue(dbName, json);
  472. }
  473. }
  474.  
  475. function cleanLocal(text) {
  476. var result = [];
  477. if (text !== "undefined" && text.length > 0) {
  478. var split = text.split("\n");
  479. for (i = 0; i < split.length; i++) {
  480. var line = split[i].trim();
  481. if (line.length === 0) continue;
  482. if (line.match(/^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}\s-\slocalhost.*/)) {
  483. continue;
  484. } else {
  485. result.push(line);
  486. }
  487. }
  488. text = result.join("\n");
  489. }
  490. return text;
  491. }
  492.  
  493. if (window.location.href.indexOf("legacy.hackerexperience.com/log") != -1) {
  494. var log = $('form.log').find('.logarea');
  495. if (log && log.length > 0) {
  496. text = log.val();
  497. saveIPs("localDb", scrapeIPs(cleanLocal(text)));
  498. }
  499. }
  500.  
  501. if (window.location.href.indexOf("legacy.hackerexperience.com/internet?view=logs") != -1) {
  502. var log = $('form.log').find('.logarea');
  503. if (log && log.length > 0) {
  504. text = log.val();
  505. saveIPs("internetDb", scrapeIPs(text));
  506. }
  507. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement