Advertisement
Guest User

SCRIPT

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