So I got a recent job where I need to connect a program to a SQL server, and I was looking to do it via a PHP tunnel to avoid people sniffing the SQL password and whatnot. The problem is that they can sniff the tunnel and still fuck up my shit pretty bad. I'm currently using just a simple PHP page with a get function to querry the server, although, obviously, that's horribly insecure. I also wrote a simple encryption algorithm which obscures what the program is doing, but still, simple enough to sniff out and just shoot the command back at the server, and considering the encryption is mostly server sided as I don't have a VB6 equivelent, it makes things rather hard. This is the code I'm using.
Just a simple test to see if this works:
PHP Code:
<?
include("encrypt.php");
$text = "SHOW TABLES";
$ck = "thisshitis4realnukka";
$encrypted_string = encrypt($text,$ck);
$decrypted_string = decrypt($encrypted_string,$ck);
echo "<b>Encryption Results:</b><br>Encrypted the following string: $text<br>Encrypted Value: $encrypted_string<br>Decrypted Value: $decrypted_string";
mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("Databasename") or die(mysql_error());
echo '<br>Connected!';
$strGet = str_replace("キ", "'", $_GET['idk']);
$query = decrypt($strGet,$ck);
$result = mysql_query($query) or die('[ Error: ' .mysql_error() .' ]');
echo "<table>\n";
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($row as $value) {
echo "\t\t<td>$value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
mysql_free_result($result);
mysql_close($link);
?>
while it does work, if they just take my encrypted string and send it back it would still execute the command.
I use winsock on the VB6 end and just parse the data that is gotten.
and ideas? I was thinking of editing the request packet so that it had an encripted string in it, but even then, a simple sniffer would get that.
Sorry, not so good with problems like this. Hope you understood my problem
Been up for a long time trying to get this working. 6 red bulls and 3 starbuck expressos later, still stuck on the same problem
Thanks!