Feb 15

This is a rather simple way to create an image from a string. You can use this for whatever you want to, but my thought would be for posting e-mail addresses or maybe a CAPTCHA of some sort. You could do all sorts of stuff with this, like base64ing it or encrypting it with AES. All you need to do is upload this file in a new folder and name it index.php, then create an .htaccess file and you're done. You can now just link to it like this:

<img src="http://yoursite.com/folder/this is your string">

index.php:

<?php
$fontnum = 5; // 1-5
$max_str_length = 100; // maximum length of one line of text
header("Content-type: image/png"); // tell the browser this is an image
if(@$_SERVER['REQUEST_URI']){
	$str = urldecode(str_replace(dirname($_SERVER['PHP_SELF']) . "/", "", $_SERVER['REQUEST_URI'])); // get the string
}
$str = chunk_split($str, $max_str_length); // split up the text into chunks based on max length
$str = substr(str_replace("\r", "", $str),0, -1); // replace \r (fucks things up)
$lines = count(explode("\n", $str)); // find the number of lines
$height = imagefontheight($fontnum)*count(explode("\n", $str)); // determine height
$width = imagefontwidth($fontnum) * ($lines <= 1 ? strlen($str) : $max_str_length); // determine width
$i = imagecreatetruecolor($width, $height); // create the base image
$str = explode("\n", $str); // create the string
for($x=0;$x<$lines;$x++){
	imagestring($i,$fontnum,0,(imagefontheight($fontnum)*$x),$str[$x],imagecolorallocate($i, 255, 255, 255)); // add each line to the image
}
imagepng($i); // output the image
?>

.htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>

Example of your new script

Enjoy :)

Feb 11

I don't know a whole lot about encryption, but this is something I wrote for a project I was working on. I'd be interested to hear how it could be improved and/or its strengths and weaknesses. Obviously any encryption scheme that is this short presents a time problem, it being very quick as compared to other algorithms. However, my goal with this one was simplicity and some level of security.

function x($str, $key){
	$num = round(strlen($str)/strlen($key));
	$key_tmp = str_repeat($key, ($num >= 1 ? $num : 1));
	$encrypted = $str ^ $key_tmp;
	return $encrypted;
}
Dec 28

Here's a quick function I wrote to generate IP address ranges using recursion.

function iprange($oct, $prefix=""){
	for($i=1;$i<256;$i++){
		if($oct == 1) print("$prefix.$i\\n");
		else iprange($oct - 1, "$prefix.$i");
	}
}

Just call it with the number of octets you want to generate and the beginning of the IP range.

Example:

iprange(2, "127.0");

Output:

127.0.1.1
127.0.1.2
127.0.1.3
127.0.1.4
127.0.1.5

127.0.255.254
127.0.255.255

Enjoy :)

Dec 19

A while back when I was first learning AJAX, I decided I wanted to write an interactive PHP/JavaScript shell for executing commands, etc. All the other ones I found either didn't handle directories well, were way too bulky or were backdoored. So, I now present to you JAXED Shell. I haven't extensively tested it, but it should work in the majority of situations.

Enjoy :)
Commands:

home - return to shell's home directory
clear - clear history box
up/down arrow - go through previous commands
right arrow - file name completion

Read the rest of this entry »

Dec 17

Wrote this for one of my projects - hopefully it helps you out a little bit. POST data needs to be formatted variable1=value&variable2=value2 and urlencoded.

function CURL($url, $postdat=""){
	$ch = curl_init($url);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
	if($postdat){
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $postdat);
	}
	while(!$dat) $dat = curl_exec($ch);
	curl_close($ch);
	return $dat;
}

Examples:

$dat = CURL("http://google.com");
$dat = CURL("http://site.com/post.php", "search=bunnies");

Sorry I haven't had much content lately: finals this week :-\

« Previous Entries