Hacking _root variables with Firefox
-migrated-
Hacking _root variables with Firefox Posted on: 03/08/2010 1:19pm
Quote Post

While i'm new to root vars myself. I made a little script to insert an easy way to do root var hacking, as I didn't want to go through the trouble of trying to do it with CE.

Caution should be used when hacking multiplayer games that save data and have ban systems. This changes any var to string. Which could result in values being combined rather than added. Which could result in bans. Use at your own risk in these situations

-----------------
This requires the Greasemonkey Extension.

What this script will do is Place 2 input fields, 1 for the Var Name, and one for the Value to set. Simply click submit to change it.

Simply enough really.

UserScript Code
-----------------
DO NOT use the "Select All" button on the code tab, it will cause every line to be prefixed by 4 spaces, which will cause the script to import incorrectly. Just Select it yourself then copy.

Code: [Select]
// ==UserScript==
// @name Kongregate Root Var Hacking
// @namespace Infamousblob
// @description Easy way hack with root vars
// @include http://*.kongregate.com/games/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
// @version 0.2
// @date 2010-03-10
// ==/UserScript==

//Only loads this code on the main window
if(window.top == window.self)
{
//Increase's window size to show the form

var gameiframe = document.getElementById('gameiframe');
var maingame = document.getElementById('maingame');
maingame.style.height = parseInt(maingame.style.height) + 30 + 'px';
gameiframe.height = Math.min(gameiframe.height) + 30;

}
else
{
// Inserts Jquery and Jquery UI into the iframe header, so it can be utilized and anything else JQ we need
var GM_JQ = document.createElement('script');
GM_JQ.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js';
GM_JQ.type = 'text/javascript';
var GM_JQUI = document.createElement('script');
GM_JQUI.src = 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js';
GM_JQUI.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(GM_JQ);
document.getElementsByTagName('head')[0].appendChild(GM_JQUI);

var CSS = '<style type="text/css">';
CSS += '#rv_hack_box { background-color:#3D3D3D; border:1px #1D1D1D solid;padding:5px; width:25px; color:#fff; position:relative; }';
CSS += '#rv_hack_form { display:none; }';
CSS += '#rv_draghandle { background-color:#000; border:1px #1D1D1D solid; color:#fff; padding:3px; font-size:8px; float:left; }';
CSS += '#rv_hide { background-color:#000; border:1px #1D1D1D solid; color:#fff; padding:3px; font-size:8px; float:right; }';
CSS += '</style>'
$('head').append(CSS);

//This makes the Flash Object Transparent so HTML can float over it
$('#gamediv').append('<param name="wmode" value="transparent" />');

//JS to run it all
var RV_JS = '<script type="text/javascript">';
RV_JS += 'var rv_intervals = new Array();'
RV_JS += 'function rv_change(varname,varvalue){document.getElementById("gamediv").SetVariable("_root."+varname,varvalue);}function rv_freeze(varname,varvalue){if(rv_intervals[varname])clearInterval(rv_intervals[varname]);if(varname==""||varvalue=="")return;rv_intervals[varname]=setInterval("rv_change('"+varname+"', '"+varvalue+"')",1);}function rv_unfreeze(varname){clearInterval(rv_intervals[varname]);}';
RV_JS += '$(function() { ';
RV_JS += '$("#rv_hack_box").draggable({ snap: "#game_wrapper", handle: "#rv_draghandle" });';
//RV_JS += '$("#rv_hack_box").position({top:"-400px" });alert($(window).height());'
RV_JS += '$("#rv_draghandle").hover(function() { $(this).css("cursor","move"); }, function() { $(this).css("cursor","auto");});';
RV_JS += '$("#rv_hide").hover(function() { $(this).css("cursor","pointer"); }, function() { $(this).css("cursor","auto");});';
RV_JS += '$("#rv_hide").toggle(function(){$(this).text("-").attr("title", "Hide");$("#rv_hack_form").show();$("#rv_hack_box").width(100);},function(){$(this).text("+").attr("title", "Show");$("#rv_hack_form").hide();$("#rv_hack_box").width(25);});';
RV_JS += '$("#rv_change").click(function() { document.getElementById("gamediv").SetVariable("_root."+$("#varname").val(), $("#varvalue").val()); });';
RV_JS += '$("#rv_freeze").click(function() { rv_freeze($("#varname").val(), $("#varvalue").val());});';
RV_JS += '$("#rv_unfreeze").click(function() { rv_unfreeze($("#varname").val());});';
RV_JS += '});';
RV_JS += '</script>';
$('#game_wrapper').append(RV_JS);

//HMTL for it all
var RV_HTML = '<div id="rv_hack_box">';
RV_HTML += '<div id="rv_draghandle" title="Move">+</div><div id="rv_hide" title="Show">+</div><br />';
RV_HTML += '<form action="#maingame" onsubmit="return false;" name="rv_hack_form" id="rv_hack_form">';
RV_HTML += 'Varname: <input id="varname" type="text" size="8" name="varname" /><br />';
RV_HTML += 'Value: <input id="varvalue" type="text" size="8" name="varvalue" /><br />';
RV_HTML += '<input type="button" value="Change" id="rv_change" />';
RV_HTML += '<input type="button" value="Freeze" id="rv_freeze" />';
RV_HTML += '<input type="button" value="UnFreeze" id="rv_unfreeze" />';
RV_HTML += '</form></div>';
$('#game_wrapper').append(RV_HTML);
}

How to Install
-----------------
  • Copy the above code.
  • Create a file named something.user.js
  • Open with a Text Editor of your choice.
  • Paste the above code into it.
  • Save it.
  • Drag the JS file into the page area of Firefox
  • When prompted "install" the script.


How to Upgrade
-----------------
Version 0.1 to 0.2
Do Not just Edit the file and copy the new code in, I added a require (Jquery). So it requires to be re-installed. To do this just repeat the install steps above. Future versions should not need to do this, and may just edit the script and paste in.

How to use
-----------------
The menu will appear in the bottom left under the game. You will initially see 2 +'s Left one is for draggin the box around (will snap to the flash windows edge's), the right will Toogle Show/Hide

--Basics
-----------------

The var will already be prefixed with "_root." so all you need is the var name itself

Example: Mad Karate Man - Mad Points
The Rootvar you would use for Cheat Engine is "_level0/:cash" so what we need is after the _level0/: which is "cash"

Enter "cash" as the var name and whatever value you want. Click submit.

And poof your Mad Points have change

--Freezing
-----------------
New feature allows you to freeze values. This is done every 1 millisecond.

Simply enter your information like normal and click Freeze.
Var's will stay frozen unless you Unfreeze them by clicking unfreeze.

If you decide later to unfreeze a var after you have already changed it, simply just enter the name in again and click unfreeze

Notes
-----------------
If you see root vars listed with " _root." just ignore this part instead.

It does seem maybe some games are compiled with script access denied, which will prevent this method from working.

Changelog
-----------------
2010-03-10
  • Updated to ver 0.2
  • Reworked the code majorly
  • Added Jquery and Jquery UI injections into Kongregate Iframe
  • Added Jquery into the script for easier manipulation
  • Menu is now Dragable(and snapable to flash window edges), and has Show/Hide Toggle
  • Added Freeze/Unfreeze Feature at roughly 1ms intervals

-----------------
Let me know if you have any problems with this
Re: Hacking _root variables with Firefox Posted on: 03/08/2010 9:15pm
Quote Post
changing electrum doesnt really work.
for example..
1. change electrum to 100
2. buy something worth 30
3. i have 70 left, like normal.
4. change it back to 100
5. go to oracle, win 30 electrum
6. i have 10030 electrum.. instead of 130.
7. instabanned (broken image removed)

im completely new to this so maybe i did something wrong, i dunno.
Re: Hacking _root variables with Firefox Posted on: 03/08/2010 9:31pm
Quote Post
Good job (broken image removed) Haven't tried it yet, but it looks great.

Quote from: "peterabott"
changing electrum doesnt really work.
for example..
1. change electrum to 100
2. buy something worth 30
3. i have 70 left, like normal.
4. change it back to 100
5. go to oracle, win 30 electrum
6. i have 10030 electrum.. instead of 130.
7. instabanned (broken image removed)

im completely new to this so maybe i did something wrong, i dunno.
I think that by setting the variable through SetVariable, you converted it to a string.
Re: Hacking _root variables with Firefox Posted on: 03/08/2010 10:12pm
Quote Post
After some testing yea I had that happen to me.

However you can do this
Change Electrum
Buy what you want
Let it save
Refresh the page to reload
Then it will be like you never modified with it.

I'll try a few things, like parseInt() on the value but I think SetVariable will cause it to be string regardless
Re: Hacking _root variables with Firefox Posted on: 03/09/2010 12:24am
Quote Post
TIM the Enchanter
Level: 1
ADR Info
Typical issue that Rag had. Stuff would become a string once altered. The only way to change it back, I believe, is in native flash, and we don't have access to that. (broken image removed)




Everything's coming up KongHack!

"When you know nothing matters, the universe is yours" ~Rick Sanchez

Re: Hacking _root variables with Firefox Posted on: 03/09/2010 8:15am
Quote Post
Can't we just freeze the value?
Re: Hacking _root variables with Firefox Posted on: 03/09/2010 10:58am
Quote Post
Ah thats a good thought, I could put in a button to freeze a value
Re: Hacking _root variables with Firefox Posted on: 03/09/2010 5:10pm
Quote Post
works for me hahah
Re: Hacking _root variables with Firefox Posted on: 03/09/2010 11:49pm
Quote Post
about the freezing bit, i installed the script fine, but when i tried it with mad karate man, the money wouldn't stay at the set value. haven't tried it w/other games yet, but just wondering if I did anything wrong
Re: Hacking _root variables with Firefox Posted on: 03/10/2010 1:40am
Quote Post
There is no freezing feature yet
Re: Hacking _root variables with Firefox Posted on: 03/10/2010 2:21am
Quote Post
Quote from: "Infamousblob"
There is no freezing feature yet
ah, no wonder. no hurry, but this will make root vars a lot quicker
Re: Hacking _root variables with Firefox Posted on: 03/10/2010 10:16am
Quote Post
I'm working on some various improvements
The new section will be movable, and be able to move it (sadly this will be limited into the iframe itself, but you will be able to drag it ontop of the flash if you wanted.

I'm also thinking of a feature, where People can save and store root vars for a game, and they will load for that page, and be selectable from a drop down. These could also be shared or something of the sort.

But 1 thing at a time.
Re: Hacking _root variables with Firefox Posted on: 03/10/2010 11:27am
Quote Post
Huh, a ragnarok that doesn't need IE to work and will work across virtually all versions of Kong? I like. Serious up karma for you dude, if you get the freeze function set in I'll give you more.



Check before you post, someone may have beaten you there.

Don't fear my banhammer, fear the God holding it...

Re: Hacking _root variables with Firefox Posted on: 03/10/2010 5:53pm
Quote Post
Updated. Can read the changelog at the bottom of first post. Please also read "How to Upgrade" As I made a few changes that require it to be re-installed and not just edited.
Re: Hacking _root variables with Firefox Posted on: 03/10/2010 9:31pm
Quote Post
I did everything step by step, I have the script installed and I see it ticked in the GreaseMonkey menu, but I do not see the GUI for the actual hack, as displayed here: