The other day I posted a link to Slavehack, the online hacking game, and I've been pretty much addicted to it since then. I wrote a little script to edit logs so that it replaces digits with x's. This useful because it cuts down your log editing time by a lot. You need FireFox and GreaseMonkey for this to work. Just install the script, go to a log, and you're ready to go.
My friend showed me a cool "hacking" game called SlaveHack. It's sort of fun, even if it's not realistic. Go check it out. ![]()
PHP Version:
function toascii($s){
$tmp = "";
for($i=0;$i<strlen($s);$i++){
$tmp .= "&#" .hexdec(bin2hex($s[$i])) . ";";
}
return htmlentities($tmp);
}
Python Version:
import urllib def encodeDork(s): tmp = "" for i in xrange(0,len(s)): tmp += "&#" + str(int(binascii.b2a_hex(s[i]), 16)) + ";" return urllib.quote(tmp)
Something quick I did.. Very useful for blocked Google queries ![]()
For whatever reason, the ternary operator is not used very often in PHP. Hell, I didn't even know what it was until several months ago. However, it is a very useful tool. Basically, it's a short way of condensing if statements with only one result. Example:
if($_GET['variable'] == "yes"){
$flag = true;
}
else{
$flag = false;
}
That's 6 lines of code for something that is VERY simple. Let's look at the ternary operator version:
$flag = $_GET['variable'] == "yes" ? true : false;
One line! Much better. Let me explain how this works. When using the ternary operator, you have 3 statements, arranged like so:
[statement 1] ? [statement 2] : [statement 3]
They evaluate like this: if [statement 1] evaluates true, then [statement 2], or else [statement 3]. So, in our example, if you set the $_GET['variable'] to "yes", $flag would equal true, otherwise it is set to false. However, it's not just limited to one statement. For example:
$flag = $_GET['variable'] == "yes" ? ($_GET['variable2'] != "no" ? true : false) : false;
If $_GET['variable'] is yes, and $_GET['variable2'] isn't no, then flag is true, otherwise it is false. That would've taken a lot more code without the ternary operator, wouldn't it? Yet we managed to do it in an entire one line.
- Number 1: HijackThis

Description: Hijackthis is an excellent spyware scanner and remover. It is, in my opinion, the best free spyware software available. It also has other useful functions such as deleting files on startup, disabling startup processes, and viewing DLLs in use by running processes.
Link: MajorGeeks.com



