Wednesday, 23 September 2015

MSSQL Context_Info session value global value.

How to store and read bits from a session value called Context_Info.



SET Context_Info 0xFF; -- bitindex is the value of the bit you want to get for example 7 is a value of 64 or 0x40 -- CONVERT(tinyint,bitindex value) & SUBSTRING(Context_Info(),byteoffset+1, 1) select CONVERT(tinyint,0x01) & SUBSTRING(Context_Info(),1,1) AS '1', CONVERT(tinyint,0x02) & SUBSTRING(Context_Info(),1,1) AS '2', CONVERT(tinyint,0x04) & SUBSTRING(Context_Info(),1,1) AS '4', CONVERT(tinyint,0x08) & SUBSTRING(Context_Info(),1,1) AS '8', CONVERT(tinyint,0x10) & SUBSTRING(Context_Info(),1,1) AS '16', CONVERT(tinyint,0x20) & SUBSTRING(Context_Info(),1,1) AS '32', CONVERT(tinyint,0x40) & SUBSTRING(Context_Info(),1,1) AS '64', CONVERT(tinyint,0x80) & SUBSTRING(Context_Info(),1,1) AS '128'


You can also store strings in it.

DECLARE @MyStatus VARBINARY(128); SET @MyStatus = CAST('TEST' AS VARBINARY(128)); SET Context_Info @MyStatus; SELECT CAST(Context_Info() AS VARCHAR) -- Or substring :D SELECT CAST(SUBSTRING(CONTEXT_INFO(), 1, 4) AS VARCHAR)



This Context_Info value could be useful to store a value for the session and change the control flow of a trigger.

Monday, 19 January 2015

Moving from Tomboy to GNote for note keeping on ubuntu.

So I had a bunch of notes stored in Tomboy on an older version of ubuntu.

When I upgraded to a newer version of linux I found out I just could not use tomboy notes.
I read somewhere that tomboy was officially removed as a default note app/in apt-get repository the author of that message recommended GNote.

When I installed it, it conflicted with google chrome and uninstalled that automatically.
Re installing chrome would remove Tomboy.

The solution is to use GNote which I think is actually nicer and to copy the *.note files from tomboy to your gnote directory in ~/.local/share/.

sudo apt-get update && sudo apt-get install gnote
cp ~/.local/share/tomboy/*.note ~/.local/share/gnote/


You may also want to auto start gnote

mkdir ~/.config/autostart
cp /usr/share/applications/gnote.desktop ~/.config/autostart/
chmod u+x ~/.config/autostart/gnote.desktop


Thanks to http://www.irrational.net/2012/04/27/moving-from-tomboy-to-gnote/

Wednesday, 14 May 2014

Oracle Database not replicating or SSL not working.

Check the date time on the server/computer.....
Make sure its set correctly, Enable Network Time Protocol syncing....

Check the cmos battery.
Yip we had a powercut and a machine we are using as a db server had the cmos battery go flat so the date was in the past. Records created after that date were not synchronized to other servers and the logs were of little use.

Thursday, 27 March 2014

Preventing spelling mistakes with Sublime spell checking

So people seem to get annoyed at spelling mistakes in my comments and code.
I'm not very good at English. Turns out sublime has a solution.

I just have to enable these settings under Preferences Settings - Default or Settings - User etc.
"spell_check": true,
"dictionary": "Packages/Language - English/en_GB.dic"

If you use US spelling you could set your dictionary too
"dictionary": "Packages/Language - English/en_US.dic"

Yeah.. I use GB at work because I live in New Zealand and we spell things with UK spellings.
Eg Colour not Color. I much prefer US spelling but not much that I can do about that since everyone else would expect things to be spelt how they want right?

https://www.sublimetext.com/docs/2/spell_checking.html

It adds commands to the right click menu when right clicking on words where you can ignore or see list of corrections. And words are underlined with a red triangle wave squiggle.

It checks comments and strings in ' ' " " etc.

Very Useful.

Saturday, 22 March 2014

Signature Scanning

I have been getting a lot of questions about Signature Scanning such as

  • What is a signature?
  • How do I find or make one?
  • Where would signature scanning be usefull?


People seem to think this is a hard thing to do so I want to try simplify it.
Basicaly code such as C++ is compiled it is turned into byte code that the computer can run.

When memory hacking we find bytes we want to modify but if the application is recompiled or uses dynamic memory
The address is not garruented to be the same each time the app runs.

A signature is a sequence of bytes and wild cards to find in memory.

I have a game here, and it has a version string rendered in the bottom left.
You may be able to see VER9.02

I wanted to get that version as well as modify it to include my own text.

So I used cheat engine and searched for a string of VER9.02
I had to have Writable and Executable checkboxs set half way so that Cheat engine would scan
readable and executable memory too.

After I found the version string address.
I found what accessed the code.

Which can be done two ways, scan for the address in hex and goto the address -1 in the Memory View dissasembler
Or right click the entry and find what accesses.

I can just scroll up a little bit and look at the bytes on the left. Any references to other memory addresses
will change on recompile, such as ones seen in the PUSH or MOV or CALL op codes
Generally if the value is in the code sections of the executable it will be suspect to change.
Simply make those bytes wild card with the ?? when writing them down. You can search the signature in cheat engine
As an array of bytes with hex turned on.


Signature Scanner: https://code.google.com/p/signiturescanner/


Video can be found here: https://www.youtube.com/watch?v=WmHDQzfELxk


Thursday, 26 December 2013

Reversing data to figure out the math behind generating values using Eureqa Pro

So I needed an easy way to get the formulars back from the data in a game.
For example to know how Damage and Chance to Hit are calculated so that I can emulate this server side.

I needed something simple to use, there was R which I learnt about at work but its unnessecarly complex.

Erueqa Pro has a spreadsheet interface to enter your data, you define var for each column.
dex hitrate
1 5
2 10
3 15
4 20
5 25
6 30
7 35
8 41
9 46
10 51
11 56
12 61
13 66
14 71
15 77
16 82
17 87
18 92
19 97
20 102

I then went to the Set Target area. I knew Floor, Ceil or Round must be used as the value is always a whole number but the total goes up in a pattern like 3 2 2 2 3 2 2 3 2 2 2 which tells me theres flooring or something going on.
http://www.nutonian.com/download/eureqa-desktop-download/